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

java.net.URL.equals implements non-commutative comarison

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      sparc
    • OS:
      solaris_2.5, solaris_2.5.1
    • Verification:
      Verified

      Description



      Name: yyC67448 Date: 01/29/98



      The java.net.URL.equals(URL) returns true when the URL without an anchor is
      compared with the same URL with the anchor added.

      For example equals returns true on following two urls:
      http://web2.javasoft.com/index.html
      http://web2.javasoft.com/index.html#SomeAnchor

      Source code inspection shows, that anchors are not compared, when the current
      object has no anchor specified.

      Here is the test demonstrating the bug:

      -------------------------------- Test.java -----------------------------
      import java.net.*;

      class test
      {

        public static void main(String args[])
        {
        URL url = null;
        URL url1 = null;
        
        try {
          url = new URL("http://web2.javasoft.com/index.html");
          url1 = new URL("http://web2.javasoft.com/index.html#SomeAnchor");
        } catch(Exception e)
        {
          System.out.println("Unexpected exception :" + e);
          System.exit(-1);
        }

        if(url1.equals(url))
        {
          System.out.println("Failed. ");
          System.exit(-1);
        }

        if(!url.equals(url1))
        {
          System.out.println("OKAY");
          System.exit(0);
        }
        else
        {
          System.out.println("Failed. ");
          System.exit(-1);
        }
      }

      }

      ---------------------- Output from the test --------------------
      Failed.
      -----------------------------------------------------------------

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mmcclosksunw Michael Mccloskey (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: