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

   _Claude Code on behalf of Guillaume Nodet_
   
   ## Critical Issue #2: Race Condition with Filesystem State
   
   **Location:** `AbstractSurefireMojo.java` - multiple calls to 
`nestedModuleDirectories()`
   
   **Problem:**
   The code calls `nestedModuleDirectories(getMainBuildPath())` multiple times:
   1. In `scanDirectories()` - line ~1072
   2. In `newStartupConfigWithModularPath()` - line ~2162
   
   Between these calls, the filesystem could change (especially during parallel 
Maven builds), leading to inconsistent state.
   
   **Impact:** 
   - Scan phase might find no nested modules
   - Later, startup config phase finds nested modules
   - Module patching and package opening become inconsistent
   - Tests may fail with ClassNotFoundException or module access errors
   
   **Recommendation:** 
   ```java
   // At class level, compute once and cache
   private List<File> nestedModuleDirs = null;
   
   private List<File> getNestedModuleDirectories() {
       if (nestedModuleDirs == null) {
           nestedModuleDirs = nestedModuleDirectories(getMainBuildPath());
       }
       return nestedModuleDirs;
   }
   ```
   Then use `getNestedModuleDirectories()` throughout instead of calling 
`nestedModuleDirectories()` directly.


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