RFR: 8367561: Getting some "header" property from a file:// URL causes a file descriptor leak [v3]
Daniel Fuchs
dfuchs at openjdk.org
Tue Oct 7 14:45:36 UTC 2025
On Tue, 7 Oct 2025 11:36:16 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:
>> Jaikiran Pai has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
>>
>> - Daniel's suggestion - don't repeat/copy code from super()
>> - merge latest from master branch
>> - missed pushing the change
>> - 8367561: fix inputstream leak
>> - 8367561: introduce tests
>
> src/java.base/share/classes/sun/net/www/protocol/file/FileURLConnection.java line 258:
>
>> 256: is = new BufferedInputStream(new FileInputStream(file.getPath()));
>> 257: }
>> 258: return is;
>
> 90% of this work – i.e., getting the file listing – is already done in `connect()`. `getInputStream()` only concatenates `directoryListing`. Moving this last 10% logic to `connect()`, making it populate a
>
> private Supplier<InputStream> inputStreamSupplier;
>
> field, can simplify the code. Have you considered this route?
I'm guessing this is going to be a candidate for backporting - so let's keep the changes minimum. I'd rather keep that code in getInputStream() as it conceptually belong there.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27633#discussion_r2410873623
More information about the net-dev
mailing list