wet-boew/spring-boot-thymeleaf

BreadcrumbServiceImpl throws ConcurrentModificationException under heavy load

sellersj opened this issue · 1 comments

There is some code that is not thread safe and it will throw an error under heavy load.

Message: Controller thrown error in EFilling application java.util.ConcurrentModificationException 
    at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:730) ~[?:1.8.0] 
    at java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:758) ~[?:1.8.0] 
    at ca.canada.ised.wet.cdts.components.wet.breadcrumbs.BreadcrumbServiceImpl.insertHomePage(BreadcrumbServiceImpl.java:223) ~[wet-cdts-spring-boot-thymeleaf-starter-4.0.32.0.jar:4.0.32.0] 
    at ca.canada.ised.wet.cdts.components.wet.breadcrumbs.BreadcrumbServiceImpl.checkApplicationHome(BreadcrumbServiceImpl.java:199) ~[wet-cdts-spring-boot-thymeleaf-starter-4.0.32.0.jar:4.0.32.0] 
    at ca.canada.ised.wet.cdts.components.wet.breadcrumbs.BreadcrumbServiceImpl.getBreadCrumbList(BreadcrumbServiceImpl.java:143) ~[wet-cdts-spring-boot-thymeleaf-starter-4.0.32.0.jar:4.0.32.0] 
    at ca.canada.ised.wet.cdts.components.wet.interceptor.WETTemplateInterceptor.setBreadCrumbs(WETTemplateInterceptor.java:197) ~[wet-cdts-spring-boot-thymeleaf-starter-4.0.32.0.jar:4.0.32.0] 
    at ca.canada.ised.wet.cdts.components.wet.interceptor.WETTemplateInterceptor.postHandle(WETTemplateInterceptor.java:100) ~[wet-cdts-spring-boot-thymeleaf-starter-4.0.32.0.jar:4.0.32.0] 
    at org.springframework.web.servlet.HandlerExecutionChain.applyPostHandle(HandlerExecutionChain.java:151) ~[spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:974) [spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) [spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) [spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) [javax.j2ee.servlet.jar:?] 
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) [javax.j2ee.servlet.jar:?] 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1233) [com.ibm.ws.webcontainer.jar:?] 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782) [com.ibm.ws.webcontainer.jar:?] 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481) [com.ibm.ws.webcontainer.jar:?] 
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) [com.ibm.ws.webcontainer.jar:?] 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) [com.ibm.ws.webcontainer.jar:?] 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) [com.ibm.ws.webcontainer.jar:?] 
    at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:63) [spring-webmvc-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) [com.ibm.ws.webcontainer.jar:?] 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [com.ibm.ws.webcontainer.jar:?] 
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:281) [spring-boot-actuator-1.3.8.RELEASE.jar:1.3.8.RELEASE] 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.28.RELEASE.jar:4.3.28.RELEASE] 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) [com.ibm.ws.webcontainer.jar:?]

Spring session scoped beans were being overridden in the singleton with a new bean. This destroyed the session scoped bean.

I've checked in a fix after writing a test that I ran with up to 100k threads.

Fix should be in the 4.0.32.2 version or newer.