Skip to content

Improve the stability of tag binding#4882

Merged
nscuro merged 1 commit intoDependencyTrack:masterfrom
nscuro:tag-binding-stability
Apr 26, 2025
Merged

Improve the stability of tag binding#4882
nscuro merged 1 commit intoDependencyTrack:masterfrom
nscuro:tag-binding-stability

Conversation

@nscuro
Copy link
Copy Markdown
Member

@nscuro nscuro commented Apr 26, 2025

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 ConcurrentModificationException being thrown. Using an Iterator prevents this from happening.

Addressed Issue

N/A

Additional Details

N/A

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

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]>
@nscuro nscuro added technical debt backport/4.13.1 PRs to be backported to v4.13.1 labels Apr 26, 2025
@nscuro nscuro added this to the 4.14.0 milestone Apr 26, 2025
@owasp-dt-bot
Copy link
Copy Markdown

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

@nscuro nscuro requested a review from Copilot April 26, 2025 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@codacy-production
Copy link
Copy Markdown

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 91.67% (target: 70.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3c3d486) 23968 19311 80.57%
Head commit (36d869c) 23974 (+6) 19317 (+6) 80.57% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4882) 12 11 91.67%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@nscuro nscuro merged commit 792c420 into DependencyTrack:master Apr 26, 2025
11 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2025
@nscuro nscuro deleted the tag-binding-stability branch March 26, 2026 23:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/4.13.1 PRs to be backported to v4.13.1 technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants