RFR: 8359808: JavaRuntimeURLConnection should only connect to non-directory resources [v3]

Alan Bateman alanb at openjdk.org
Sat Jun 21 09:08:38 UTC 2025


On Wed, 18 Jun 2025 12:58:29 GMT, David Beaumont <duke at openjdk.org> wrote:

>> David Beaumont has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Feedback changes and renaming field to match nomenclature of JEP 220.
>
> src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java line 101:
> 
>> 99:             }
>> 100:             this.resource = node;
>> 101:             super.connected = true;
> 
> I know I don't *need* to use super here, but it documents the fact that this is not a field of this subclass, without readers having to go check. Mutable protected fields are weird and error prone, so I felt calling it out a bit was worth it. Happy to replace with a comment if people feel that's better though.

Sadly, many of the JDK 1.0 era APIs expose protected fields for subclasses, in this case URLConnection.

One thing that is a bit icky is for a getXXX method to have the side effect to set this field. Maybe this is connectNode or something to suggest it connects the URLConnection?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25871#discussion_r2159984080


More information about the net-dev mailing list