On Mon, 22 May 2023 16:10:17 GMT, Bernd <d...@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

Reply via email to