JDK-6746185 : Malformed URL Exception: JWS regression introduced in 1.5.0_16
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: deploy
  • Sub-Component: webstart
  • Priority: P1
  • Affected Version: 5.0,5.0u17
  • OS: generic,linux,windows_xp
  • CPU: generic,x86
  • Submit Date: 2008-09-09
  • Updated Date: 2014-02-27
  • Resolved Date: 2008-10-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
1.0.1_08Resolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 5.2.3790]

A DESCRIPTION OF THE PROBLEM :
MalformedURLException did not occur in identical application code in 1.5.0_12.  Occurs in 1.5.0_16 when the following sequence is executed when running under Java WebStart (only):

URL resourceBase = MyClass.class.getResource("myfile");
URL newURL = new URL(resourceBase, "anotherfile");

Exception appears to be thrown because sun.net.www.protocol.jar.Handler.parseURL() has the following sequence of code:

            int bangSlash = indexOfBangSlash(file);
            String toBangSlash = file.substring(0, bangSlash);

But indexOfBangSlash(string) returns -1 if it doesn't find !/ in the URL's file property.

But in this scenario only the realURL property of the handler has the full path, and the file property has only the relative path.

Therefore, a StringIndexOutOfBoundException is thrown, which is translated to a MalformedURLException.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
when running under Java WebStart (only):

URL resourceBase = MyClass.class.getResource("myfile");
URL newURL = new URL(resourceBase, "anotherfile");

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
URL should be valid, context should be applied as defined.
ACTUAL -
MalformedURLException is thrown.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
String index out of range: -1
causing MalformedURLExcpeption


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
when running under Java WebStart (only):

URL resourceBase = MyClass.class.getResource("myfile");
URL newURL = new URL(resourceBase, "anotherfile");

Ensure that "myfile" and "anotherfile" are resources in the same package in the same jar.  [Sorry this is not compilable as such -- but scenario requires resources in jars, deployed via JNLP]
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None found.

Release Regression From : 5.0u12
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION Have the JnlpURLStreamHandler class handle toString() requests.
2008-10-14