AbstractAnalyzeMojo.filterDependencies() at line 568-573:
for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); ) {
Artifact artifact = it.next();
if (!filter.include(artifact)) {
it.remove(); // mutates the ORIGINAL set passed in
result.add(artifact);
}
}
This method is called multiple times on the same set with different filter arrays (lines 363-375):
ignoredUsedUndeclared.addAll(filterDependencies(usedUndeclaredWithClasses.keySet(), ignoredDependencies));
ignoredUsedUndeclared.addAll(filterDependencies(usedUndeclaredWithClasses.keySet(), ignoredUsedUndeclaredDependencies));
After the first non-empty filter removes matching entries from usedUndeclaredWithClasses, the second call operates on an already-reduced set. The "Used undeclared dependencies found:" warning listing (line 392, 394) iterates usedUndeclaredWithClasses which has been destructively modified — entries matching ignoredDependencies are silently missing from the warning output.
The same pattern applies to unusedDeclared and nonTestScope (lines 367-375).
The method should either:
- Copy the set before iterating, or
- Build the result without removing from the input, leaving the caller responsible for subtraction
AbstractAnalyzeMojo.filterDependencies()at line 568-573:This method is called multiple times on the same set with different filter arrays (lines 363-375):
After the first non-empty filter removes matching entries from
usedUndeclaredWithClasses, the second call operates on an already-reduced set. The "Used undeclared dependencies found:" warning listing (line 392, 394) iteratesusedUndeclaredWithClasseswhich has been destructively modified — entries matchingignoredDependenciesare silently missing from the warning output.The same pattern applies to
unusedDeclaredandnonTestScope(lines 367-375).The method should either: