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

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

    Details

    • Subcomponent:
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5, windows_nt

      Description



      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
      ---------------------------------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mullan Sean Mullan
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: