Improve the stability of tag binding#4882
Conversation
This is mostly a preventative change than one based on actual issues encountered. Removing from a collection that is being iterated over is not supported and should usually lead to a `ConcurrentModificationException` being thrown. Using an `Iterator` prevents this from happening. Signed-off-by: nscuro <[email protected]>
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) |
There was a problem hiding this comment.
Pull Request Overview
This PR improves the stability of tag binding by replacing in-loop removals with iterator-based removals to prevent ConcurrentModificationExceptions.
- Replace for-each removal loops with iterator removal in ProjectQueryManager, PolicyQueryManager, and NotificationQueryManager.
- Add necessary imports to support iterator usage.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/org/dependencytrack/persistence/ProjectQueryManager.java | Updated tag removal loop using an iterator. |
| src/main/java/org/dependencytrack/persistence/PolicyQueryManager.java | Updated tag removal loop using an iterator. |
| src/main/java/org/dependencytrack/persistence/NotificationQueryManager.java | Updated tag removal loop using an iterator. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Description
Improves the stability of tag binding.
This is mostly a preventative change than one based on actual issues encountered.
Removing from a collection that is being iterated over is not supported and should usually lead to a
ConcurrentModificationExceptionbeing thrown. Using anIteratorprevents this from happening.Addressed Issue
N/A
Additional Details
N/A
Checklist
This PR fixes a defect, and I have provided tests to verify that the fix is effectiveThis PR implements an enhancement, and I have provided tests to verify that it works as intendedThis PR introduces changes to the database model, and I have added corresponding update logicThis PR introduces new or alters existing behavior, and I have updated the documentation accordingly