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

URL.sameFile and equals methods work wrong in presense of default ports

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5.1



      Name: yyC67448 Date: 01/29/98



      The java.net.URL.sameFile and java.net.URL.equals both return false when
      comparing two URLs one of which has default port explicity specified.

      For example sameFile and equals methods return false on following two urls:
      http://web2.javasoft.com/index.html
      http://web2.javasoft.com:80/index.html


      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:80/index.html");
        } catch(Exception e)
        {
          System.out.println("Unexpected exception :" + e);
          System.exit(-1);
        }

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

      }

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

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: