RFR: JDK-6956385: URLConnection.getLastModified() leaks file handles for jar:file and file: URLs [v3]

Daniel Fuchs dfuchs at openjdk.org
Mon May 22 16:34:52 UTC 2023


On Mon, 22 May 2023 16:10:17 GMT, Bernd <duke at openjdk.org> wrote:

>> See discussion at https://github.com/openjdk/jdk/pull/12871#discussion_r1198932229.
>
> It does not address the question if it needs to close more than the file: protocol.
> 
> (And it still feels like a layering violation, should maybe the metadata function initializeHeaders close its own stream - balanced with connect())?

If we wanted to make JarURLConnection call AutoCloseable::close (or Closeable::close) when the underlying URLConnection is `AutoCloseable` - that would be a change of behaviour that would be observable by custom URLConnection implementations provided by custom URL Stream Handler.

That would be a change of behavior requiring a CSR, and it might not be appropriate for backport, due to potential backward compatibility issue (well - that would be a matter to discuss in the CSR anyway).

That's why I would advise to not try to do this in this PR. If we wanted to do it - we should probably log an RFE for that. Also examine what it means for `URL.openConnection()` to return an object that implements `AutoCloseable`. A the very least, an `@apiNote` would be needed in URL API documentation. 

Unless this really solves some real hard issue (as opposed to theoretical issues) for which we have no solution today, I would be very prudent with making wider changes to this old, intricate, and hard to maintain piece of code.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/12871#discussion_r1200754171


More information about the net-dev mailing list