On Wed, 8 Oct 2025 13:23:39 GMT, Daniel Fuchs <[email protected]> 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

Reply via email to