elharo opened a new issue, #1646:
URL: https://github.com/apache/maven-dependency-plugin/issues/1646

   `AbstractAnalyzeMojo.filterDependencies()` at line 568-573:
   
   ```java
   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):
   
   ```java
   
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:
   1. Copy the set before iterating, or
   2. Build the result without removing from the input, leaving the caller 
responsible for subtraction


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to