Fix ConcurrentModificationException in getDeclaredResources and getResourcesFromProject#1020
Open
mPokornyETM wants to merge 2 commits intomasterfrom
Open
Fix ConcurrentModificationException in getDeclaredResources and getResourcesFromProject#1020mPokornyETM wants to merge 2 commits intomasterfrom
mPokornyETM wants to merge 2 commits intomasterfrom
Conversation
14ee18f to
ca0f61d
Compare
Contributor
|
⏳ Auto-merge countdown: This PR will be auto-approved in 2 day(s) if no review is submitted. |
ca0f61d to
d5d96f3
Compare
Contributor
|
|
…sourcesFromProject Add synchronized(syncResources) blocks around iterations in getDeclaredResources() and getResourcesFromProject() to prevent ConcurrentModificationException when the resources list is modified concurrently by another thread. Also changes both methods to iterate over this.resources directly (inside the sync block) instead of this.getResources() which returns an unprotected reference. Fixes #933
d5d96f3 to
c595918
Compare
Contributor
|
⏸️ Auto-merge countdown PAUSED: CI checks are not passing. The countdown will resume when all checks are green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes ConcurrentModificationException reported in JENKINS-64127 / #933.
Two methods in LockableResourcesManager iterated over the
esources list without synchronization, while other threads could modify it concurrently:
Fix
Wrap both methods in \synchronized(syncResources)\ and iterate over \ his.resources\ directly (instead of \ his.getResources()\ which returns an unprotected reference).
Analysis
The original issue listed 10 methods. Of those:
Testing
Existing tests cover both methods (\ConfigurationAsCodeTest, \LockRunListener\ integration tests). All pass.
Fixes #933