Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 197861 - Incorrect URL port value in JarClassLoader
Incorrect URL port value in JarClassLoader
Product: platform
Classification: Unclassified
Component: Module System
PC Linux
: P1 (vote)
: 6.x
Assigned To: Jaroslav Tulach
Depends on:
  Show dependency treegraph
Reported: 2011-04-19 09:16 UTC by Jaroslav Tulach
Modified: 2011-04-20 05:01 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT

I cannot reproduce the faulty behavior, URLs seem to be equal (3.68 KB, patch)
2011-04-19 10:24 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2011-04-19 09:16:54 UTC uses a literal of 0. This causes URL.equals(Object) to fail when comparing URLs that were 
constructed using the different means. 

The URL spec violation is that they are setting the port without setting the 
host.  The specification prohibits that.  If the host is not set, the port 
must be -1.  The standard URL constructors ensure this is always the case.   
However, JarClassLoader bypasses those constructors and calls 
URLStreamHandler.setURL(), and explicitly sets the port to 0.  They need to 
change that code to be consistent with URLs created with the standard 
constructors, and use -1.  Should only be a 2 character change in the file, I 
Comment 1 Jaroslav Tulach 2011-04-19 10:24:20 UTC
Created attachment 107830 [details]
I cannot reproduce the faulty behavior, URLs seem to be equal
Comment 2 Jaroslav Tulach 2011-04-19 12:28:35 UTC
To reproduce one needs to use URL(u, "/relative/path"): ergonomics#63fed943e185

Jesse, please review, I'd like to put the fix into release692 branch.
Comment 3 Jesse Glick 2011-04-19 17:17:43 UTC
Fix looks OK to me.

Note that new URL("jar:file:/....jar!/...").getHost() => "" rather than null, which will be another difference from the current code. Probably it makes no difference.

Would prefer that testURLsAreEqual be moved inside JarClassLoaderTest, probably right beneath testJarURLConnection, so that Ctrl-F6 from runs all relevant tests.
Comment 4 Jaroslav Tulach 2011-04-19 19:11:08 UTC
changeset:   a6da24c443cd
branch:      release692
parent:      591d43f0314b
parent:      63fed943e185
user:        Jaroslav Tulach <>
date:        Tue Apr 19 21:02:06 2011 +0200
summary:     Backport of #197861 to release692 branch

I started with the test in JarClassLoaderTest, but it does not work. It needs to obtain URL from the original handler first, and only then initialize JarClassLoader. This is a bit fragile, and it is better to isolate this into own test case.
Comment 5 Quality Engineering 2011-04-20 05:01:21 UTC
Integrated into 'main-golden', will be available in build *201104200000* on (upload may still be in progress)
User: Jaroslav Tulach <>
Log: #197861: Copy the host and port

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo