United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6746185 Malformed URL Exception: JWS regression introduced in 1.5.0_16
JDK-6746185 : Malformed URL Exception: JWS regression introduced in 1.5.0_16

Details
Type:
Bug
Submit Date:
2008-09-09
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2008-10-22
Component:
deploy
OS:
linux,generic,windows_xp
Sub-Component:
webstart
CPU:
x86,generic
Priority:
P1
Resolution:
Fixed
Affected Versions:
5.0,5.0u17
Fixed Versions:
5.0u17 (b03)

Related Reports
Backport:
Backport:
Duplicate:
Duplicate:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

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



Hardware and Software, Engineered to Work Together