Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6746185

Malformed URL Exception: JWS regression introduced in 1.5.0_16

    Details

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      generic, x86
    • OS:
      generic, linux, windows_xp

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  coffeys Sean Coffey
                  Reporter:
                  ndcosta Nelson Dcosta
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: