You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/07/04 19:30:15 UTC

[I] Unclosed Files.walk() stream in getOutputDirectoryPerVersion() [maven-compiler-plugin]

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: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Unclosed Files.walk() stream in getOutputDirectoryPerVersion() [maven-compiler-plugin]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo closed issue #1070: Unclosed Files.walk() stream in getOutputDirectoryPerVersion()
URL: https://github.com/apache/maven-compiler-plugin/issues/1070


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org