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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



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

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: