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

invalid URL (protocol only) not detected by URL() constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs
    • None
    • generic
    • solaris_9

      daniel.daugherty@Eng 1999-08-02

      The following java program illustrates the bug:

      File repro2.java:

      import java.net.*;

      public class repro2 {
          public static void main(String[] args) {
      try {
      //
      // According to Section 3 of RFC 2396, the scheme and colon
      // must be followed by a scheme specific component. While
      // some protocols may allow an empty scheme specific
      // component, the http protocol does not.
      //
      URL url = new URL("http:");
      System.err.println("Test FAILed:"
      + " URL constructor did not throw exception.");
      } catch (MalformedURLException e) {
      System.out.println("Test PASSed: URL constructor threw exception.");
      // Expect MalformedURLException: no protocol: http:
      System.out.println(e.getMessage());
      }
          }
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: