# HG changeset patch # User chegar # Date 1297087727 0 # Node ID 6bf10e07111718b4981ae2220d7581b4e75e94b5 # Parent 526b9179a2bbfac3608286f01fe10535e8dd04d7 7016898: PlainSocketImpl.fd is null on Windows Reviewed-by: alanb diff -r 526b9179a2bb -r 6bf10e071117 jdk/src/windows/classes/java/net/PlainSocketImpl.java --- a/jdk/src/windows/classes/java/net/PlainSocketImpl.java Mon Feb 07 13:55:40 2011 +0000 +++ b/jdk/src/windows/classes/java/net/PlainSocketImpl.java Mon Feb 07 14:08:47 2011 +0000 @@ -138,6 +138,9 @@ protected synchronized void create(boolean stream) throws IOException { impl.create(stream); + + // set fd to delegate's fd to be compatible with older releases + this.fd = impl.fd; } protected void connect(String host, int port) @@ -166,7 +169,7 @@ impl.doConnect(address, port, timeout); } - protected synchronized void bind(InetAddress address, int lport) + protected synchronized void bind(InetAddress address, int lport) throws IOException { impl.bind(address, lport); @@ -174,9 +177,13 @@ protected synchronized void accept(SocketImpl s) throws IOException { // pass in the real impl not the wrapper. - ((PlainSocketImpl)s).impl.address = new InetAddress(); - ((PlainSocketImpl)s).impl.fd = new FileDescriptor(); - impl.accept(((PlainSocketImpl)s).impl); + SocketImpl delegate = ((PlainSocketImpl)s).impl; + delegate.address = new InetAddress(); + delegate.fd = new FileDescriptor(); + impl.accept(delegate); + + // set fd to delegate's fd to be compatible with older releases + s.fd = delegate.fd; } void setFileDescriptor(FileDescriptor fd) { @@ -208,11 +215,21 @@ } protected void close() throws IOException { - impl.close(); + try { + impl.close(); + } finally { + // set fd to delegate's fd to be compatible with older releases + this.fd = null; + } } void reset() throws IOException { - impl.reset(); + try { + impl.reset(); + } finally { + // set fd to delegate's fd to be compatible with older releases + this.fd = null; + } } protected void shutdownInput() throws IOException {