URL constructor throws NullPointer rather than MalformedURL if file is null

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 1.2.0
    • Component/s: core-libs
    • x86
    • windows_nt



      Name: dbT83986 Date: 03/09/99


      Trying to instantiate a URL using the constructor
      URL(String, String, String) results in a NullPointerException
      rather than the expected MalformedURLException if the following
      values are supplied

      import java.io.*;
      import java.net.*;

      public class URLTest
      {

      public static void main(String args[])
      {
      try{
      URL u = new URL("http", "java.sun.com", null);
      }
      catch (MalformedURLException mue)
      {
      System.out.println("Caught MalformedURLException " + mue );
      }
      catch (Exception e)
      {
      System.out.println("Caught unexpected exception " + e );
      }
      }

      }


      Running the above code produces the output

      security properties not found. using defaults.
      Caught unexpected exception java.lang.NullPointerException:

      output of java -fullversion is
      java full version "JDK-1.2-V"

      Suspect code is probably trying to parse the ref in file, without
      first checking whether file is null.
      (Review ID: 54723)
      ======================================================================

            Assignee:
            Unassigned
            Reporter:
            Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: