gnodet commented on PR #3392:
URL: https://github.com/apache/maven-surefire/pull/3392#issuecomment-7394438356

   _Claude Code on behalf of Guillaume Nodet_
   
   ## Critical Issue #3: Package List Cleared - Potential Data Loss
   
   **Location:** `AbstractSurefireMojo.java` line ~2184
   
   **Problem:**
   When nested layout is detected:
   ```java
   if (nestedLayout) {
       packages.clear();  // <-- Discards all previously collected packages
       packages.addAll(scanTestPackages(patchFile));
       additionalModuleArgs = createAdditionalModuleArgs(testDir, 
additionalModules);
   }
   ```
   
   The `packages` set was populated earlier at line ~2140 with packages from 
`scanResult.getClasses()`. If that scan included:
   - Packages from dependency scanning
   - Packages from non-filesystem sources
   - Packages from other providers
   
   They are all lost after `clear()`.
   
   **Impact:**
   - Tests in dependency packages may lose `--add-opens` directives
   - Reflection access denied for those packages
   - Test execution failures
   
   **Recommendation:**
   1. If dependency packages should be preserved, use `addAll` instead of 
`clear() + addAll`
   2. If only patchFile packages are needed, document why dependency packages 
can be safely discarded
   3. Consider whether `scanTestPackages(patchFile)` captures everything needed 
for nested layout


-- 
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