--- a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java Tue Apr 30 19:34:13 2019 +0100
+++ b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java Fri May 03 08:26:44 2019 +0100
@@ -74,6 +74,12 @@
/* indicates connection reset state */
private volatile boolean connectionReset;
+ /* indicates whether impl is bound */
+ boolean isBound;
+
+ /* indicates whether impl is connected */
+ volatile boolean isConnected;
+
/* whether this Socket is a stream (TCP) socket or not (UDP)
*/
protected boolean stream;
@@ -105,6 +111,10 @@
return isReusePortAvailable;
}
+ AbstractPlainSocketImpl(boolean isServer) {
+ super(isServer);
+ }
+
/**
* Returns a set of SocketOptions supported by this impl and by this impl's
* socket (Socket or ServerSocket)
@@ -148,10 +158,6 @@
socketCreate(true);
SocketCleanable.register(fd);
}
- if (socket != null)
- socket.setCreated();
- if (serverSocket != null)
- serverSocket.setCreated();
}
/**
@@ -180,6 +186,7 @@
it will be passed up the call stack */
}
}
+ isConnected = connected;
}
}
@@ -195,6 +202,7 @@
try {
connectToAddress(address, port, timeout);
+ isConnected = true;
return;
} catch (IOException e) {
// everything failed
@@ -236,6 +244,7 @@
it will be passed up the call stack */
}
}
+ isConnected = connected;
}
}
@@ -393,7 +402,7 @@
synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException {
synchronized (fdLock) {
- if (!closePending && (socket == null || !socket.isBound())) {
+ if (!closePending && !isBound) {
NetHooks.beforeTcpConnect(fd, address, port);
}
}
@@ -407,14 +416,6 @@
throw new SocketException ("Socket closed");
}
}
- // If we have a ref. to the Socket, then sets the flags
- // created, bound & connected to true.
- // This is normally done in Socket.connect() but some
- // subclasses of Socket may call impl.connect() directly!
- if (socket != null) {
- socket.setBound();
- socket.setConnected();
- }
} finally {
releaseFD();
}
@@ -433,15 +434,12 @@
throws IOException
{
synchronized (fdLock) {
- if (!closePending && (socket == null || !socket.isBound())) {
+ if (!closePending && !isBound) {
NetHooks.beforeTcpBind(fd, address, lport);
}
}
socketBind(address, lport);
- if (socket != null)
- socket.setBound();
- if (serverSocket != null)
- serverSocket.setBound();
+ isBound = true;
}
/**
@@ -727,7 +725,7 @@
socketClose0(false);
}
- abstract void socketCreate(boolean isServer) throws IOException;
+ abstract void socketCreate(boolean stream) throws IOException;
abstract void socketConnect(InetAddress address, int port, int timeout)
throws IOException;
abstract void socketBind(InetAddress address, int port)