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

Jesse Glick duke at openjdk.org
Fri May 19 15:27:00 UTC 2023


On Fri, 19 May 2023 15:13:49 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Curiously, this method appears to never be called; at least
>> 
>> 
>> diff --git src/java.base/share/classes/sun/net/www/URLConnection.java src/java.base/share/classes/sun/net/www/URLConnection.java
>> index b3af24c594b..f346cd8869b 100644
>> --- src/java.base/share/classes/sun/net/www/URLConnection.java
>> +++ src/java.base/share/classes/sun/net/www/URLConnection.java
>> @@ -253,14 +253,6 @@ public abstract class URLConnection extends java.net.URLConnection {
>>                  REMIND */ ;
>>      }
>>  
>> -    /**
>> -     * Call this to close the connection and flush any remaining data.
>> -     * Overriders must remember to call super.close()
>> -     */
>> -    public void close() {
>> -        url = null;
>> -    }
>> -
>>      private static HashMap<String,Void> proxiedHosts = new HashMap<>();
>>  
>>      public static synchronized void setProxiedHost(String host) {
>> 
>> 
>> does not cause
>> 
>> 
>> make images
>> 
>> 
>> to fail, though it seems that the JDK source base does not currently enforce use of `@Override`. (I did not find any overrides from a text search, and if there were some without the annotation, they were apparently not calling `super.close()`.)
>
> Interesting. If it's not called anywhere maybe we could investigate adding `throws IOException` to the signature...

That is also an option of course; would be binary compatible. Happy to take that approach if you think it would be clearer.

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

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


More information about the net-dev mailing list