Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentModificationException when doing a merge on AbstractEnvironment [SPR-13213] #17805

Closed
spring-projects-issues opened this issue Jul 8, 2015 · 1 comment
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 8, 2015

Stephen Liang opened SPR-13213 and commented

I seem to get an occasional ConcurrentModificationException when doing a merge on various different threads. Perhaps merge() needs to be synchronized?

Caused by: java.util.ConcurrentModificationException
        at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373)
        at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:384)
        at java.util.AbstractCollection.toArray(AbstractCollection.java:171)
        at org.springframework.util.StringUtils.toStringArray(StringUtils.java:816)
        at org.springframework.core.env.AbstractEnvironment.getDefaultProfiles(AbstractEnvironment.java:268)
        at org.springframework.core.env.AbstractEnvironment.merge(AbstractEnvironment.java:437)
        at org.springframework.context.support.AbstractApplicationContext.setParent(AbstractApplicationContext.java:402)
        at org.springframework.context.support.GenericApplicationContext.setParent(GenericApplicationContext.java:148)
        at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.createFlowApplicationContext(FlowModelFlowBuilder.java:336)
        at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.initLocalFlowContext(FlowModelFlowBuilder.java:302)
        at org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder.doInit(FlowModelFlowBuilder.java:147)
        at org.springframework.webflow.engine.builder.support.AbstractFlowBuilder.init(AbstractFlowBuilder.java:46)
        at org.springframework.webflow.engine.builder.FlowAssembler.assembleFlow(FlowAssembler.java:90)
        at org.springframework.webflow.engine.builder.DefaultFlowHolder.assembleFlow(DefaultFlowHolder.java:109)
        at org.springframework.webflow.engine.builder.DefaultFlowHolder.getFlowDefinition(DefaultFlowHolder.java:84)
        at org.springframework.webflow.definition.registry.FlowDefinitionRegistryImpl.getFlowDefinition(FlowDefinitionRegistryImpl.java:61)
        at org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:138)
        at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
        at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
        ... 227 more

Affects: 3.2.8

Issue Links:

Referenced from: commits d2447ce, e393c7b, af5f4e6

Backported to: 4.1.8, 3.2.15

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

It looks like this may be caused by AbstractEnvironment's lazy resolution of the "spring.profiles.default" property... since for that reason, a call to doGetActiveProfiles may actually lead to a manipulation of the activeProfiles Set, which may in turn break a concurrent attempt to turn it into a String array in getDefaultProfiles. We'll make this more defensive for 4.2.2, backporting the fix to 4.1.8 if it is straightforward enough.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants