-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Creating ApplicationContexts from multiple threads causes ConcurrentModificationException [SPR-10543] #15173
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
Comments
Juergen Hoeller commented This isn't surprising since we generally expect an ApplicationContext to fully refresh in a single thread before getting exposed to other threads. In other words, it's only meant to be accessed concurrently after the refresh phase. We have plans to revisit this for Spring Framework 4.0, but for the time being, I'm afraid your scenario is simply not supported. Juergen |
James Shaw commented Many thanks for your feedback Juergen. Just to check I understand correctly, you're saying that Spring 3 doesn't support separate ApplicationContexts being created in separate threads? Can you explain what state is being shared between ApplicationContext instances and why? |
Juergen Hoeller commented No, I just meant to say that any given ApplicationContext should not get exposed to other threads before its refresh phase completed. Independent ApplicationContexts should be able to bootstrap concurrently just fine, as long as they are not sharing any kind of configuration state. Juergen |
James Shaw commented Ok, but in my test case, I don't think I'm sharing ApplicationContexts between threads, so it should bootstrap successfully, no? |
Juergen Hoeller commented Sorry, didn't notice your attached repro project before... I think I know what's going on there now: You're using the same This has been addressed for 4.0 M1 in the form of reworked configuration class processing which uses instance state only now - and therefore should not lead to any sharing between concurrent ApplicationContexts, even if they register the very same Hope that helps, Juergen |
Juergen Hoeller commented I assume that this issue has been addressed along with #14941. Please reopen it if this still doesn't work for you against 4.0 M1 (to be released tomorrow). Juergen |
Uh oh!
There was an error while loading. Please reload this page.
James Shaw opened SPR-10543 and commented
See testcase to reproduce. Backtrace:
I've also seen deadlocks occurring when running my integration tests in parallel, but I've been unable to reduce those to a test case.
Affects: 3.2.2
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: