RFR: 8367561: Getting some "header" property from a file:// URL causes a file descriptor leak [v3]

Jaikiran Pai jpai at openjdk.org
Wed Oct 8 13:32:15 UTC 2025


On Wed, 8 Oct 2025 13:23:39 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> If I'm not mistaken at least FileInputStream has a cleaner to close its file descriptor:
>> https://github.com/openjdk/jdk/blob/23fcbb0badbef6d22f63ca6c5b26b0693002592c/src/java.base/share/classes/java/io/FileInputStream.java#L140
>
> Thanks for adding the reachability fence. An other possibility would have been to temporarily stash `conn` in a static field.

> If I'm not mistaken at least FileInputStream has a cleaner to close its file descriptor:
> 
> https://github.com/openjdk/jdk/blob/23fcbb0badbef6d22f63ca6c5b26b0693002592c/src/java.base/share/classes/java/io/FileInputStream.java#L140


You are right indeed - I have stared at that constructor code for several minutes but hadn't spotted this. I had additionally done a text search for "cleaner" in that class and only found their references in the javadoc text. Thank you for catching this. GC could indeed have played a role here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27633#discussion_r2413869709


More information about the net-dev mailing list