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

http:/server.host.com is accepted by new URL( )

    XMLWordPrintable

Details

    • x86
    • solaris_2.6, windows_98

    Description

      Name: diC59631 Date: 05/27/98


      How come

      http:/server.host.com is accepted by:
      new URL (String)
      without causing an exception

      but

      ftp:/server.host.com is not?

      Of course neither should be - or am I doing something really stupid here


      Simon
      (Review ID: 32279)
      ======================================================================

      Name: skT88420 Date: 05/28/99


      /*
      The following URL fails to generate a MalformedURLException:

        http:/java.sun.com

      Furthermore, the following URL gets "fixed" to the one above,
      which is still wrong:

        http:java.sun.com

      Although this bug is presumably cross platform, I only attempted
      to reproduce it under Windows 98.

      */

      import java.net.*;

      public class UrlBug
      {
        public static void main(String[] args)
        {
          URL theUrl;
          String src="";
          try
          {
            src = "http:java.sun.com";
            theUrl = new URL(src);
            System.out.println("URL 1 -- <" + theUrl + ">");

            src = "http:/java.sun.com";
            theUrl = new URL(src);
            System.out.println("URL 2 -- <" + theUrl + ">");

            System.out.println("\nNo MalformedURLException detected");
          }
          catch (MalformedURLException ex)
          {
            System.out.println("Bad URL: " + src);
          }
        }
      }
      (Review ID: 83633)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              jccollet Jean-Christophe Collet (Inactive)
              dindrigo Daniel Indrigo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: