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

The java.net.URL constructor allows null host parameter for http and

XMLWordPrintable

    • x86, sparc
    • solaris_2.5, windows_nt



      Name: yyC67448 Date: 12/29/97



      The java.net.URL(String protocol, String host, int port, String file)
      constructor allows null host parameter for http and ftp url's.


      Here is the test demonstrating the bug:

      ------------------------ Test.java ---------------------------------------
      import java.net.*;

      public class Test
      {
        public static void main(String args[])
        {
         URL ftp_url = null;
         URL http_url = null;
         String host = null;
         String file = "/index.html";
         int port = -1;
         

         try {
           ftp_url = new URL("ftp", host, port, file);
           http_url = new URL("http", host, port, file);
         } catch(MalformedURLException e)
         {
             System.out.println("Passed. OKAY");
             System.exit(0);
         }
         catch(Exception e)
         {
           System.out.println("Unexpected exception:" + e);
           System.exit(-1);
         }

          System.out.println("No exceptions");
          System.exit(-1);
        }
         
      }
      ------------------------- Output from the test ----------------------------
      No exceptions
      ---------------------------------------------------------------------------

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

            mullan Sean Mullan
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: