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

Socket constructors throw unspecified NPE

XMLWordPrintable

    • b05
    • generic, sparc
    • generic, solaris_2.6
    • Verified

        Name: ktR10099 Date: 12/19/2003



        According to the spec constructors of javax.net.ssl.SSLSocket class throw
        IOException or UnknownHostException. But current java implementation
        throws NPE for the following constructors:

        protected SSLSocket(InetAddress address, int port)
        protected SSLSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort)

        Please find below example, demonstrating the problem:
        ---------------------------test145.java------------------------------
        import javax.net.ssl.SSLSession;
        import javax.net.ssl.SSLSocket;
        import javax.net.ssl.HandshakeCompletedListener;
        import java.net.InetAddress;
        import java.io.IOException;

        public class test145 {
            public static void main(String[] args) {
                try {
                    MySSLSocket ms = new MySSLSocket((InetAddress)null, 8080);
                } catch (Exception e) {
                    System.out.println(e);
                }
                try {
                    MySSLSocket ms = new MySSLSocket((InetAddress)null, 8080, (InetAddress)null, 8080);
                } catch (Exception e) {
                    System.out.println(e);
                }
                System.out.println("Finished");
            }
        }

        class MySSLSocket extends SSLSocket {
            public MySSLSocket() throws IOException {
                super();
            }

            public MySSLSocket(InetAddress address, int port) throws IOException {
                super(address, port);
            }

            public MySSLSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort) throws IOException {
                super(address, port, clientAddress, clientPort);
            }

            public MySSLSocket(String host, int port) throws IOException {
                super(host, port);
            }

            public MySSLSocket(String host, int port, InetAddress clientAddress, int clientPort) throws IOException {
                super(host, port, clientAddress, clientPort);
            }

            public void addHandshakeCompletedListener(HandshakeCompletedListener listener) {}

            public String[] getEnabledCipherSuites() {
                return null;
            }

            public String[] getEnabledProtocols() {
                return null;
            }

            public boolean getEnableSessionCreation() {
                return false;
            }

            public boolean getNeedClientAuth() {
                return false;
            }

            public SSLSession getSession() {
                return null;
            }

            public String[] getSupportedCipherSuites() {
                return null;
            }

            public String[] getSupportedProtocols() {
                return null;
            }

            public boolean getUseClientMode() {
                return false;
            }

            public boolean getWantClientAuth() {
                return false;
            }

            public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {}

            public void setEnabledCipherSuites(String[] suites) {}

            public void setEnabledProtocols(String[] protocols) {}

            public void setEnableSessionCreation(boolean flag) {}

            public void setNeedClientAuth(boolean need) {}

            public void setUseClientMode(boolean mode) {}

            public void setWantClientAuth(boolean want) {}

            public void startHandshake() {}
        }
        ----------------------output of test145-------------------------
        java full version "1.5.0-beta-b31"
        java.lang.NullPointerException
        java.lang.NullPointerException
        Finished
        ----------------------------------------------------------------
        ======================================================================

              jccollet Jean-Christophe Collet (Inactive)
              kvtsunw Kvt Kvt (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: