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

David Beaumont duke at openjdk.org
Mon Jun 23 11:16:31 UTC 2025


On Fri, 20 Jun 2025 16:20:37 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java line 119:
>> 
>>> 117:     public long getContentLengthLong() {
>>> 118:         try {
>>> 119:             return getResourceNode().size();
>> 
>> Having getResourceNode() return the (lazily fetched) node avoids the reader needing to know/reason about how "connect()" has the side-effect of making the "resource" field non-null.
>
> It looks like ExplodedImage.PathNode.size() throws UncheckedIOException. That might need mapping back to IOException to get the -1 return consistently.

Done. That's a good spot (I comment it since it's a real gotcha otherwise).

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

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


More information about the net-dev mailing list