From a0b7ecd3d1bae05f46cdaee038d675d5d51886b7 Mon Sep 17 00:00:00 2001 From: Chris Hegarty <chegar@openjdk.org> Date: Mon, 7 Feb 2011 14:08:47 +0000 Subject: [PATCH] 7016898: PlainSocketImpl.fd is null on Windows Reviewed-by: alanb --- .../classes/java/net/PlainSocketImpl.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/jdk/src/windows/classes/java/net/PlainSocketImpl.java b/jdk/src/windows/classes/java/net/PlainSocketImpl.java index 3a963627425..cc25c39dc72 100644 --- a/jdk/src/windows/classes/java/net/PlainSocketImpl.java +++ b/jdk/src/windows/classes/java/net/PlainSocketImpl.java @@ -138,6 +138,9 @@ class PlainSocketImpl extends AbstractPlainSocketImpl 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 @@ class PlainSocketImpl extends AbstractPlainSocketImpl 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 @@ class PlainSocketImpl extends AbstractPlainSocketImpl 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 @@ class PlainSocketImpl extends AbstractPlainSocketImpl } 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 {