--- a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java Fri Mar 01 18:28:44 2019 +0000
+++ b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java Sat Mar 02 11:44:38 2019 +0000
@@ -607,15 +607,10 @@
}
}
- void reset() throws IOException {
- if (fd != null) {
- socketClose();
- }
- fd = null;
- super.reset();
+ void reset() {
+ throw new InternalError("should not get here");
}
-
/**
* Shutdown read-half of the socket connection;
*/
--- a/src/java.base/share/classes/java/net/ServerSocket.java Fri Mar 01 18:28:44 2019 +0000
+++ b/src/java.base/share/classes/java/net/ServerSocket.java Sat Mar 02 11:44:38 2019 +0000
@@ -576,6 +576,7 @@
boolean completed = false;
try {
si.reset();
+ // custom SocketImpl may expect fd/address to be created
si.fd = new FileDescriptor();
si.address = new InetAddress();
impl.accept(si);
@@ -599,19 +600,20 @@
private void implAccept(SocketImpl si) throws IOException {
assert !(si instanceof DelegatingSocketImpl);
- // A non-platform SocketImpl cannot accept a connection with a platform
- // SocketImpl
- if (!(impl instanceof PlatformSocketImpl) && si instanceof PlatformSocketImpl) {
+ // A non-platform SocketImpl cannot accept a connection with a platform SocketImpl
+ if (!(impl instanceof PlatformSocketImpl) && (si instanceof PlatformSocketImpl)) {
throw new IOException("An instance of " + impl.getClass() +
- " cannot accept a connection with an instance of " + si.getClass());
+ " cannot accept a connection with an instance of " + si.getClass());
}
+ // accept a connection
impl.accept(si);
+ // sanity check that the fields defined by SocketImpl have been set
if (si instanceof PlatformSocketImpl) {
var fd = si.fd;
- if (fd == null || !fd.valid() || si.localport <= 0 ||
- si.address == null || si.port <= 0) {
+ if (fd == null || !fd.valid() || si.localport <= 0
+ || si.address == null || si.port <= 0) {
throw new IOException("Invalid accepted state:" + si);
}
}
--- a/src/java.base/share/classes/java/net/SocketImpl.java Fri Mar 01 18:28:44 2019 +0000
+++ b/src/java.base/share/classes/java/net/SocketImpl.java Sat Mar 02 11:44:38 2019 +0000
@@ -332,7 +332,8 @@
",port=" + getPort() + ",localport=" + getLocalPort() + "]";
}
- void reset() throws IOException {
+ void reset() {
+ fd = null;
address = null;
port = 0;
localport = 0;
--- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Fri Mar 01 18:28:44 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Sat Mar 02 11:44:38 2019 +0000
@@ -1173,9 +1173,6 @@
ensureOpenAndConnected();
if (!isInputClosed) {
Net.shutdown(fd, Net.SHUT_RD);
- long reader = readerThread;
- if (reader != 0)
- NativeThread.signal(reader);
isInputClosed = true;
}
}
@@ -1187,9 +1184,6 @@
ensureOpenAndConnected();
if (!isOutputClosed) {
Net.shutdown(fd, Net.SHUT_WR);
- long writer = writerThread;
- if (writer != 0)
- NativeThread.signal(writer);
isOutputClosed = true;
}
}
@@ -1288,15 +1282,6 @@
}
/**
- * Returns the native file descriptor.
- */
- private static int fdVal(FileDescriptor fd) {
- int fdVal = SharedSecrets.getJavaIOFileDescriptorAccess().get(fd);
- assert fdVal == IOUtil.fdVal(fd);
- return fdVal;
- }
-
- /**
* Sets the SocketImpl fields to the given values.
*/
private static void setSocketImplFields(SocketImpl si,