# HG changeset patch # User alanb # Date 1549874390 0 # Node ID 7eb6cdd1204a1420fe79e48c54e6754e05afcc44 # Parent 89964144075173a8c527ce2551760eaffdd1aaac More cleanup. Also fix up jshell tests that depend on exception messages diff -r 899641440751 -r 7eb6cdd1204a src/java.base/share/classes/java/net/DelegatingSocketImpl.java --- a/src/java.base/share/classes/java/net/DelegatingSocketImpl.java Sun Feb 10 19:51:43 2019 +0000 +++ b/src/java.base/share/classes/java/net/DelegatingSocketImpl.java Mon Feb 11 08:39:50 2019 +0000 @@ -31,6 +31,8 @@ import java.util.Objects; import java.util.Set; +import sun.net.TrustedSocketImpl; + /** * A SocketImpl that delegates all methods to another SocketImpl. */ @@ -39,6 +41,7 @@ protected final SocketImpl delegate; DelegatingSocketImpl(SocketImpl delegate) { + assert delegate instanceof TrustedSocketImpl; this.delegate = Objects.requireNonNull(delegate); } diff -r 899641440751 -r 7eb6cdd1204a src/java.base/share/classes/java/net/ServerSocket.java --- a/src/java.base/share/classes/java/net/ServerSocket.java Sun Feb 10 19:51:43 2019 +0000 +++ b/src/java.base/share/classes/java/net/ServerSocket.java Mon Feb 11 08:39:50 2019 +0000 @@ -566,8 +566,11 @@ return; } - if (si instanceof DelegatingSocketImpl) + // Socket has a SOCKS or HTTP SocketImpl + if (si instanceof DelegatingSocketImpl) { si = ((DelegatingSocketImpl) si).delegate(); + assert si instanceof TrustedSocketImpl; + } // ServerSocket or Socket is using a trusted SocketImpl if (impl instanceof TrustedSocketImpl || si instanceof TrustedSocketImpl) { @@ -576,7 +579,14 @@ ? ((TrustedSocketImpl) impl).newInstance(false) : ((TrustedSocketImpl) si).newInstance(false); impl.accept(nsi); - securityCheckAccept(nsi); // closes nsi if permission check fails + try { + // a custom impl has accepted the connection with a trusted SocketImpl + if (!(impl instanceof TrustedSocketImpl)) { + nsi.postCustomAccept(); + } + } finally { + securityCheckAccept(nsi); // closes nsi if permission check fails + } // copy state to the existing SocketImpl and update socket state nsi.copyTo(si); diff -r 899641440751 -r 7eb6cdd1204a test/langtools/jdk/jshell/JdiFailingLaunchExecutionControlTest.java --- a/test/langtools/jdk/jshell/JdiFailingLaunchExecutionControlTest.java Sun Feb 10 19:51:43 2019 +0000 +++ b/test/langtools/jdk/jshell/JdiFailingLaunchExecutionControlTest.java Mon Feb 11 08:39:50 2019 +0000 @@ -38,7 +38,7 @@ public class JdiFailingLaunchExecutionControlTest { private static final String EXPECTED_ERROR = - "Launching JShell execution engine threw: Accept timed out"; + "Launching JShell execution engine threw: accept timeout"; public void failLaunchTest() { try { diff -r 899641440751 -r 7eb6cdd1204a test/langtools/jdk/jshell/JdiHangingListenExecutionControlTest.java --- a/test/langtools/jdk/jshell/JdiHangingListenExecutionControlTest.java Sun Feb 10 19:51:43 2019 +0000 +++ b/test/langtools/jdk/jshell/JdiHangingListenExecutionControlTest.java Mon Feb 11 08:39:50 2019 +0000 @@ -39,7 +39,7 @@ public class JdiHangingListenExecutionControlTest { private static final String EXPECTED_ERROR = - "Launching JShell execution engine threw: Accept timed out"; + "Launching JShell execution engine threw: accept timeout"; public void hangListenTimeoutTest() { try {