-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-9878: Fix ConcurrentModificationException in SpringIntegrationTest… #9879
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
Conversation
@@ -111,7 +111,7 @@ public void afterSingletonsInstantiated() { | |||
} | |||
|
|||
List<AbstractEndpoint> getAutoStartupCandidates() { | |||
return this.autoStartupCandidates; | |||
return new ArrayList<>(this.autoStartupCandidates); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm OK with what you are suggesting, but this has to be like Collections.unmodifiableList()
instead.
We indeed do like that in many other places where we return a collection from the object.
I missed this here because it is not public API, but as we see turns out it does not matter if we may deal with concurrent modifications. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I was just not returning unmodifiableList to not break any user, who is in fact modifying. but you're right, it's not public anyways
@SpringJUnitConfig | ||
@ContextConfiguration(classes = MockIntegrationContextTests.Config.class) | ||
@SpringIntegrationTest | ||
public class MockIntegrationContextTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just remove this new void class altogether!
I'm really not sure that registering beans in start()/stop()
is OK idea, so I don't want to promote such a pattern with our tests.
Plus the fix is really simple and it is obvious that it is going to work in your project.
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, no asterisk imports.
Also, please, add your name to the @author
list of this class.
b1faaa3
to
f89429b
Compare
…ExecutionListener Fixes: gh-9878 * return new list in MockIntegrationContext.getAutoStartupCandidates() Signed-off-by: Alexander Hain <[email protected]>
thank you very much for the contribution; looking forward for more! |
…ExecutionListener