-
Bug
-
Resolution: Fixed
-
P4
-
5.0, 6
-
b05
-
generic, sparc
-
generic, solaris_2.6
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2158554 | 6u10 | Unassigned | P2 | Closed | Won't Fix | |
JDK-2152901 | OpenJDK6 | Chris Hegarty | P3 | Resolved | Fixed | b01 |
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
----------------------------------------------------------------
======================================================================
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
----------------------------------------------------------------
======================================================================
- backported by
-
JDK-2152901 Socket constructors throw unspecified NPE
- Resolved
-
JDK-2158554 Socket constructors throw unspecified NPE
- Closed
- duplicates
-
JDK-6546669 (spec)javax.net.ssl.SSLSocket() throws undocumented exceptions
- Closed