mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-11-10 10:31:06 +00:00
Improve 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. Signed-off-by: nscuro <nscuro@protonmail.com>
This commit is contained in:
parent
3c3d4865fe
commit
36d869c968
3 changed files with 15 additions and 6 deletions
|
|
@ -75,6 +75,7 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -1392,9 +1393,11 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
}
|
||||
|
||||
if (!keepExisting) {
|
||||
for (final Tag existingTag : project.getTags()) {
|
||||
final Iterator<Tag> existingTagsIterator = project.getTags().iterator();
|
||||
while (existingTagsIterator.hasNext()) {
|
||||
final Tag existingTag = existingTagsIterator.next();
|
||||
if (!tags.contains(existingTag)) {
|
||||
project.getTags().remove(existingTag);
|
||||
existingTagsIterator.remove();
|
||||
if (existingTag.getProjects() != null) {
|
||||
existingTag.getProjects().remove(project);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue