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

URL constructor throws NullPointer rather than MalformedURL if file is null

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • 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)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: