RFR: 8289643: File descriptor leak with ProcessBuilder.startPipeline [v2]

Roger Riggs rriggs at openjdk.org
Mon Jul 11 15:02:47 UTC 2022


On Sat, 9 Jul 2022 02:43:55 GMT, David Schlosnagle <duke at openjdk.org> wrote:

>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Cleanup of PipelineLeaksFD test improving error messages and source cleanup.
>
> test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java line 130:
> 
>> 128:                 })
>> 129:                 .filter(p1 -> p1.link().toString().startsWith("pipe:"))
>> 130:                 .collect(Collectors.toSet());
> 
> Is this intentionally leaking the returned `DirectoryStream` from `Files.walk` to  trigger the previous failure mode or should this be auto-closed (i.e. https://errorprone.info/bugpattern/StreamResourceLeak )?
> 
> Suggestion:
> 
>         try (Stream<Path> s = Files.walk(path)) {
>             return s.filter(Files::isSymbolicLink)
>                     .map(p -> {
>                         try {
>                             return new PipeRecord(p, Files.readSymbolicLink(p));
>                         } catch (IOException ioe) {
>                         }
>                         return new PipeRecord(p, null);
>                     })
>                     .filter(p1 -> p1.link().toString().startsWith("pipe:"))
>                     .collect(Collectors.toSet());
>         }

@schlosna An oversight,  thanks for the reminder.

-------------

PR: https://git.openjdk.org/jdk/pull/9414


More information about the core-libs-dev mailing list