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

Fix concurrent modification exception in ExecuteDslScripts #1253

Merged
merged 2 commits into from
Oct 3, 2022
Merged

Fix concurrent modification exception in ExecuteDslScripts #1253

merged 2 commits into from
Oct 3, 2022

Conversation

gtaylor1981
Copy link
Contributor

@gtaylor1981 gtaylor1981 commented Jul 20, 2022

This PR fixes an intermittant problem we've been seeing on our builds, where alternate builds fail because of ConcurrentModificationException in ExecuteDslScripts. This was raised as JENKINS-69064.

Explanation
As part of the cleanup of removed templates in the updateTemplates() method, all seed job references are read for the removed template. These references are then filtered to those matching the seed job name. These matches are then removed from the seed job references.

However, the filtered references are a 'live' view (from Collections2.filter) based on the original seed job references, so attempting to remove them results in a ConcurrentModificationException.

Fix
The fix simply first converts the 'live' matches collection to a hash set before passing it to removeAll(), which allows the original collection to be modified. A unit test has been added to confirm this.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Copy link
Contributor

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down and resolving it 🚀

@jamietanna jamietanna merged commit b735fa6 into jenkinsci:master Oct 3, 2022
@gtaylor1981 gtaylor1981 deleted the fix/jenkins-69604-concurrent-modification-exception branch October 6, 2022 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants