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:10:59 UTC 2023
On Fri, 19 May 2023 14:40:02 GMT, Jesse Glick <duke at openjdk.org> wrote:
>>> On the other hand IIRC the `file:` protocol handler cannot be overridden - so I'm not sure whether we could actually have a custom underlying `URLConnection` - that would need to be carefully evaluated.
>>
>> Strike that. We could have of course a `jar:http://...` URL so the underlying connection is not necessarily a file connection and therefore can come from a custom protocol handler. So a CSR would definitely be needed if we started calling close() on custom URLConnections.
>
> Yes.
>
> Also I noticed that we cannot define `void close() throws IOException` here either, because of https://github.com/openjdk/jdk/blob/44218b1c9e5daa33557aac9336251cf8398d81eb/src/java.base/share/classes/sun/net/www/URLConnection.java#L256-L262 so for now I will go with another method name.
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()`.)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/12871#discussion_r1199074116
More information about the net-dev
mailing list