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

   ## Bug Description
   
   `CompilerMojo.getOutputDirectoryPerVersion()` at 
`src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java` line 350 
calls `Files.walk(root, 1)` without wrapping the result in a try-with-resources 
block. The returned `Stream<Path>` encapsulates a `DirectoryStream` handle that 
is not released until garbage collection.
   
   ## Impact
   
   On large multi-release projects with many versioned source directories, this 
can cause "Too many open files" errors because the directory streams are not 
promptly closed.
   
   ## Code
   
   ```java
   Files.walk(root, 1).forEach((path) -> {
       // ...
   });
   ```
   
   ## Fix
   
   Wrap in try-with-resources:
   
   ```java
   try (Stream<Path> stream = Files.walk(root, 1)) {
       stream.forEach((path) -> {
           // ...
       });
   }
   ```
   
   This ensures the stream (and its underlying directory handle) is closed 
immediately after processing.


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