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

java.net.Socket(SocketImpl) does not throw any Exception for null parameter

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: yyC67448 Date: 10/29/97



      The java.net.Socket(SocketImpl impl) does not throw any Exception for
      null parameter.

      Here is the test demonstrating the bug:

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

      class NewSocket extends Socket
      {
         public NewSocket(SocketImpl impl) throws SocketException
         {
      super(impl);
         }
      }



      class test
      {

        public static void main(String args[])
        {
          NewSocket soc = null;
          int port = 0;
          
           
          try {
            soc = new NewSocket((SocketImpl)null);
          } catch(Exception e)
          {
            System.out.println("OKAY");
            System.exit(-1);
          }

          try {
            port = soc.getPort();
          } catch(Exception e)
          {
            System.out.println("Failed. Unexpected exception:" +e );
            System.exit(-1);
          }


          System.out.println("OKAY");
          
        }
      }

      ---------------------- Output from the test -----------------
      Failed. Unexpected exception:java.lang.NullPointerException
      -----------------------------------------------------------------

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

            brenaudsunw Benjamin Renaud (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: