更新到 Hibernate 5.2.4 后出现 ConcurrentModificationException,Spring 4.3.3,Struts 2.5.5

ConcurrentModificationException after update to Hibernate 5.2.4, Spring 4.3.3 , Struts 2.5.5

我正在升级旧项目的框架。更新涉及几个主要版本:

  1. 休眠 3.1 -> 5.2.4
  2. Spring 2.1 -> 4.3.3
  3. Struts 2.1 -> 2.5.5
  4. Spring-安全 2.x -> 4.1.3
  5. Apache Commons Collections 3.2.1 -> 3.2.2(如果需要可以更新到 4.x)

JDK 没有受到任何更新,我们正在使用 Java 8。虽然我相信在更新之前没有使用任何 Java 8 功能的源代码。

我依靠编译器修复了所有 class 引用,更新了框架的 DTD,等等。

最后,该项目编译时只出现了一些弃用问题,没有出现任何错误。但是,一旦我加载索引页面并出现登录提示,我就会收到以下错误。

下面的代码中只有 4 个 class 不是 Spring/Strut/Hibernate 的一部分,但它们所做的只是在 Spring 安全性上调用 doFilter。简单的授权。我不创建、return 或迭代任何列表或哈希图。

欢迎任何想法。下面的完整堆栈跟踪。谢谢。

    SEVERE: Servlet.service() for servlet [default] in context with path [/FeedXLWebapp] threw exception
java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437)
    at java.util.HashMap$KeyIterator.next(HashMap.java:1461)
    at org.apache.commons.collections.iterators.IteratorEnumeration.nextElement(IteratorEnumeration.java:76)
    at java.util.ResourceBundle.handleKeySet(ResourceBundle.java:1854)
    at java.util.ResourceBundle.containsKey(ResourceBundle.java:1807)
    at org.springframework.context.support.ResourceBundleMessageSource.getStringOrNull(ResourceBundleMessageSource.java:291)
    at org.springframework.context.support.ResourceBundleMessageSource.resolveCodeWithoutArguments(ResourceBundleMessageSource.java:131)
    at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:218)
    at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:136)
    at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1249)
    at org.springframework.context.support.MessageSourceAccessor.getMessage(MessageSourceAccessor.java:83)
    at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:84)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:233)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:124)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at au.com.xprime.feedxl.accounts.security.spring.AuthenticationPostProcessingFilter.doFilterHttp(AuthenticationPostProcessingFilter.java:33)
    at au.com.xprime.feedxl.accounts.security.spring.AuthenticationPostProcessingFilter.doFilter(AuthenticationPostProcessingFilter.java:22)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:150)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at au.com.xprime.feedxl.accounts.auth.filters.BrowserCheckFilter.doFilter(BrowserCheckFilter.java:32)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at au.com.xprime.webapp.filters.ResponseCacheControlFilter.doFilter(ResponseCacheControlFilter.java:102)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
    at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
    at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    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)

所以。我认为这是我们的。问题是链式消息提取器 class.

当您有一个对象集合(如 HashMap)并且该集合中的一个对象试图将新元素附加到同一集合时,似乎会抛出并发修改异常。