demoiselle / framework

Repositório principal contendo o Core e Extensions: JPA, Security, WS
https://demoiselle.org
127 stars 77 forks source link

Erro no carregamento de configurações em cenário de concorrência #60

Closed vbuitoni closed 7 years ago

vbuitoni commented 7 years ago

Ao tentar carregar uma configuração a partir de uma classe anotada com @Configuration, em um cenário de concorrência, ocorre o erro abaixo.

É possível observar pelo trace que existem 3 threads tentando carregar a configuração simultaneamente.

41,113 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-5) Carregando a classe de configuração br.gov.fazenda.tesouro.td.configuration.CMSConfig
10:22:41,114 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-4) Carregando a classe de configuração br.gov.fazenda.tesouro.td.configuration.CMSConfig
10:22:41,115 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-2) Carregando a classe de configuração br.gov.fazenda.tesouro.td.configuration.CMSConfig
10:22:41,193 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-2) *******************************************************
10:22:41,193 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-2) Carregando a classe de configuração org.demoiselle.jee.rest.DemoiselleRestConfig
10:22:41,197 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-5) *******************************************************
10:22:41,197 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-4) *******************************************************
10:22:41,197 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-5) Carregando a classe de configuração org.demoiselle.jee.rest.DemoiselleRestConfig
10:22:41,197 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-4) Carregando a classe de configuração org.demoiselle.jee.rest.DemoiselleRestConfig
10:22:41,238 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-4) -> demoiselle.rest.gzipEnabled: [não definada na fonte de configuração do projeto, maiores informações: https://demoiselle.gitbooks.io/documentacao-jee/content/configuration-general.html]
10:22:41,241 INFO  [org.demoiselle.jee.configuration.ConfigurationLoader] (default task-4) -> demoiselle.rest.showErrorDetails: [não definada na fonte de configuração do projeto, maiores informações: https://demoiselle.gitbooks.io/documentacao-jee/content/configuration-general.html]
10:22:41,239 ERROR [io.undertow.request] (default task-5) UT005023: Exception handling request to /td-rest/api/vantagem: org.demoiselle.jee.configuration.exception.DemoiselleConfigurationException: Ocorreu um erro durante a extração do tipo boolean com o extrator org.demoiselle.jee.configuration.extractor.impl.ConfigurationPrimitiveOrWrapperValueExtractor
    at org.demoiselle.jee.configuration.ConfigurationLoader.getValueFromSource(ConfigurationLoader.java:385)
    at org.demoiselle.jee.configuration.ConfigurationLoader.fillFieldWithValue(ConfigurationLoader.java:357)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at org.demoiselle.jee.configuration.ConfigurationLoader.fillTargetObjectWithValues(ConfigurationLoader.java:336)
    at org.demoiselle.jee.configuration.ConfigurationLoader.processConfiguration(ConfigurationLoader.java:168)
    at org.demoiselle.jee.configuration.ConfigurationLoader.load(ConfigurationLoader.java:126)
    at org.demoiselle.jee.configuration.ConfigurationLoader$Proxy$_$$_WeldClientProxy.load(Unknown Source)
    at org.demoiselle.jee.configuration.ConfigurationInterceptor.constructConfiguration(ConfigurationInterceptor.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:74)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
    at org.demoiselle.jee.rest.DemoiselleRestConfig$Proxy$_$$_WeldSubclass.isShowErrorDetails(Unknown Source)
    at org.demoiselle.jee.rest.DemoiselleRestConfig$Proxy$_$$_WeldClientProxy.isShowErrorDetails(Unknown Source)
    at org.demoiselle.jee.rest.exception.treatment.ExceptionTreatmentImpl.getFormatedError(ExceptionTreatmentImpl.java:64)
    at org.demoiselle.jee.rest.exception.mapper.AnyOtherExceptionMapper.toResponse(AnyOtherExceptionMapper.java:42)
    at org.demoiselle.jee.rest.exception.mapper.AnyOtherExceptionMapper$Proxy$_$$_WeldClientProxy.toResponse(Unknown Source)
    at org.jboss.resteasy.core.ExceptionHandler.executeExceptionMapper(ExceptionHandler.java:100)
    at org.jboss.resteasy.core.ExceptionHandler.unwrapException(ExceptionHandler.java:129)
    at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:75)
    at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:220)
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:175)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:418)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
    at java.util.ArrayList$Itr.next(ArrayList.java:851)
    at org.demoiselle.jee.configuration.ConfigurationLoader.getValueFromSource(ConfigurationLoader.java:373)
    ... 73 more
clovisjunior commented 7 years ago

Olá @vbuitoni,

Poderia enviar para nós como você provocou esse bug para que possamos replicar esse erro e corrigir?

Obrigado por estar nos ajudando, toda ajuda é muito bem vinda!

vbuitoni commented 7 years ago

@clovisjunior , basicamente é um serviço REST que injeta uma classe CMSConfig, que está anotada com @Configuration(type = ConfigType.SYSTEM).

Quando este serviço é chamado de forma concorrente ocorre o erro. No caso, ocorre no carregamento de uma página de uma aplicação angular 2, que faz 3 chamadas assíncronas para serviços desta classe que injeta CMSConfig, gerando a situação de concorrência.