--- a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java Mon Feb 11 19:16:13 2019 +0000
+++ b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java Wed Feb 13 08:29:35 2019 +0000
@@ -732,11 +732,6 @@
socketClose0(false);
}
- @Override
- @SuppressWarnings("unchecked")
- public <S extends SocketImpl & PlatformSocketImpl> S newInstance(boolean server) {
- return (S) new PlainSocketImpl();
- }
@Override
public void postCustomAccept() {
--- a/src/java.base/share/classes/java/net/ServerSocket.java Mon Feb 11 19:16:13 2019 +0000
+++ b/src/java.base/share/classes/java/net/ServerSocket.java Wed Feb 13 08:29:35 2019 +0000
@@ -25,9 +25,6 @@
package java.net;
-import jdk.internal.access.JavaNetSocketAccess;
-import jdk.internal.access.SharedSecrets;
-
import java.io.FileDescriptor;
import java.io.IOException;
import java.lang.reflect.Constructor;
@@ -38,6 +35,8 @@
import java.util.Set;
import java.util.Collections;
+import jdk.internal.access.JavaNetSocketAccess;
+import jdk.internal.access.SharedSecrets;
import sun.net.PlatformSocketImpl;
/**
@@ -296,7 +295,7 @@
impl = factory.createSocketImpl();
checkOldImpl();
} else {
- impl = SocketImpl.createSocketImpl(true);
+ impl = SocketImpl.createPlatformSocketImpl(true);
}
if (impl != null)
impl.setServerSocket(this);
@@ -549,9 +548,10 @@
if (si == null) {
// create a SocketImpl and accept the connection
si = Socket.createImpl();
+ assert !(si instanceof DelegatingSocketImpl);
impl.accept(si);
try {
- // a custom impl has accepted the connection with a trusted SocketImpl
+ // a custom impl has accepted the connection with a platform SocketImpl
if (!(impl instanceof PlatformSocketImpl) && (si instanceof PlatformSocketImpl)) {
((PlatformSocketImpl) si).postCustomAccept();
}
@@ -571,15 +571,13 @@
assert si instanceof PlatformSocketImpl;
}
- // ServerSocket or Socket is using a trusted SocketImpl
+ // ServerSocket or Socket (or both) have a platform SocketImpl
if (impl instanceof PlatformSocketImpl || si instanceof PlatformSocketImpl) {
- // accept connection with new SocketImpl
- var nsi = (impl instanceof PlatformSocketImpl)
- ? ((PlatformSocketImpl) impl).newInstance(false)
- : ((PlatformSocketImpl) si).newInstance(false);
+ // create a new platform SocketImpl and accept the connection
+ var nsi = SocketImpl.createPlatformSocketImpl(false);
impl.accept(nsi);
try {
- // a custom impl has accepted the connection with a trusted SocketImpl
+ // a custom impl has accepted the connection
if (!(impl instanceof PlatformSocketImpl)) {
nsi.postCustomAccept();
}
--- a/src/java.base/share/classes/java/net/Socket.java Mon Feb 11 19:16:13 2019 +0000
+++ b/src/java.base/share/classes/java/net/Socket.java Wed Feb 13 08:29:35 2019 +0000
@@ -137,14 +137,14 @@
epoint.getPort());
}
- SocketImpl si = SocketImpl.createSocketImpl(false);
+ SocketImpl si = SocketImpl.createPlatformSocketImpl(false);
impl = (type == Proxy.Type.SOCKS) ? new SocksSocketImpl(p, si)
: new HttpConnectSocketImpl(p, si);
impl.setSocket(this);
} else {
if (p == Proxy.NO_PROXY) {
if (factory == null) {
- impl = SocketImpl.createSocketImpl(false);
+ impl = SocketImpl.createPlatformSocketImpl(false);
impl.setSocket(this);
} else
setImpl();
@@ -497,7 +497,7 @@
if (factory != null) {
return factory.createSocketImpl();
} else {
- return SocketImpl.createSocketImpl(false);
+ return SocketImpl.createPlatformSocketImpl(false);
}
}
@@ -515,7 +515,7 @@
impl = factory.createSocketImpl();
checkOldImpl();
} else {
- SocketImpl si = SocketImpl.createSocketImpl(false);
+ SocketImpl si = SocketImpl.createPlatformSocketImpl(false);
impl = new SocksSocketImpl(si);
}
if (impl != null)
--- a/src/java.base/share/classes/java/net/SocketImpl.java Mon Feb 11 19:16:13 2019 +0000
+++ b/src/java.base/share/classes/java/net/SocketImpl.java Wed Feb 13 08:29:35 2019 +0000
@@ -34,6 +34,7 @@
import java.util.Set;
import sun.net.NetProperties;
+import sun.net.PlatformSocketImpl;
import sun.nio.ch.NioSocketImpl;
/**
@@ -60,11 +61,11 @@
* Creates a instance of platform's SocketImpl
*/
@SuppressWarnings("unchecked")
- static SocketImpl createSocketImpl(boolean server) {
+ static <S extends SocketImpl & PlatformSocketImpl> S createPlatformSocketImpl(boolean server) {
if (USE_PLAINSOCKETIMPL) {
- return new PlainSocketImpl();
+ return (S) new PlainSocketImpl();
} else {
- return new NioSocketImpl(server);
+ return (S) new NioSocketImpl(server);
}
}
--- a/src/java.base/share/classes/sun/net/PlatformSocketImpl.java Mon Feb 11 19:16:13 2019 +0000
+++ b/src/java.base/share/classes/sun/net/PlatformSocketImpl.java Wed Feb 13 08:29:35 2019 +0000
@@ -34,11 +34,6 @@
public interface PlatformSocketImpl {
/**
- * Creates a new instance of this SocketImpl.
- */
- <S extends SocketImpl & PlatformSocketImpl> S newInstance(boolean server);
-
- /**
* Invoked by ServerSocket to fix up the SocketImpl state after a connection
* is accepted by a custom SocketImpl
*/
--- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Mon Feb 11 19:16:13 2019 +0000
+++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Wed Feb 13 08:29:35 2019 +0000
@@ -275,7 +275,7 @@
if (n == IOStatus.UNAVAILABLE) {
nanos -= System.nanoTime() - startTime;
if (nanos <= 0)
- throw new SocketTimeoutException("read timeout");
+ throw new SocketTimeoutException("Read timed out");
}
} while (n == IOStatus.UNAVAILABLE && isOpen());
} else {
@@ -394,15 +394,6 @@
}
/**
- * For use by ServerSocket to create a new instance of this SocketImpl.
- */
- @Override
- @SuppressWarnings("unchecked")
- public <S extends SocketImpl & PlatformSocketImpl> S newInstance(boolean server) {
- return (S) new NioSocketImpl(server);
- }
-
- /**
* For use by ServerSocket to set the state and other fields after a
* connection is accepted by a ServerSocket using a custom SocketImpl.
* The protected fields defined by SocketImpl should be set.
@@ -567,7 +558,7 @@
if (n == 0) {
nanos -= System.nanoTime() - startTime;
if (nanos <= 0)
- throw new SocketTimeoutException("connect timeout");
+ throw new SocketTimeoutException("Connect timed out");
}
} while (n == 0 && isOpen());
} else {
@@ -690,7 +681,7 @@
if (n == IOStatus.UNAVAILABLE) {
nanos -= System.nanoTime() - startTime;
if (nanos <= 0)
- throw new SocketTimeoutException("accept timeout");
+ throw new SocketTimeoutException("Accept timed out");
}
} while (n == IOStatus.UNAVAILABLE && isOpen());
} else {
--- a/test/langtools/jdk/jshell/JdiFailingLaunchExecutionControlTest.java Mon Feb 11 19:16:13 2019 +0000
+++ b/test/langtools/jdk/jshell/JdiFailingLaunchExecutionControlTest.java Wed Feb 13 08:29:35 2019 +0000
@@ -38,7 +38,7 @@
public class JdiFailingLaunchExecutionControlTest {
private static final String EXPECTED_ERROR =
- "Launching JShell execution engine threw: accept timeout";
+ "Launching JShell execution engine threw: Accept timed out";
public void failLaunchTest() {
try {
--- a/test/langtools/jdk/jshell/JdiHangingListenExecutionControlTest.java Mon Feb 11 19:16:13 2019 +0000
+++ b/test/langtools/jdk/jshell/JdiHangingListenExecutionControlTest.java Wed Feb 13 08:29:35 2019 +0000
@@ -39,7 +39,7 @@
public class JdiHangingListenExecutionControlTest {
private static final String EXPECTED_ERROR =
- "Launching JShell execution engine threw: accept timeout";
+ "Launching JShell execution engine threw: Accept timed out";
public void hangListenTimeoutTest() {
try {