java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:45470" "connect,resolve") at java.util.concurrent.CompletableFuture.reportGet(java.base@9-internal/CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get(java.base@9-internal/CompletableFuture.java:1999)

JDK Bug System | Felix Yang | 5 months ago
  1. 0

    According to the java doc " CompletableFuture<WebSocket> java.net.http.WebSocket.Builder.buildAsync() Builds a WebSocket. Returns a CompletableFuture<WebSocket> which completes normally with the WebSocket when it is connected or completes exceptionally if an error occurs. CompletableFuture may complete exceptionally with the following errors: ... • SecurityException if a security manager is set, and the caller does not have a java.net.URLPermission for the WebSocket URI ... " But, actually, it asks for following permissions: 1. java.net.URLPermission uri "GET:Sec-WebSocket-Key,Sec-WebSocket-Version" 2. java.lang.RuntimePermission "enableContextClassLoaderOverride" 3. java.net.SocketPermission "host:port" "connect,resolve" There are multiple problems here: for permission #1, is it the documented " java.net.URLPermission for the WebSocket URI "? Even yes, I suppose an example in document is needed. for permission #2, it is apparently not documented. for permission #3, not documented either. In addition, even I specified such permission, the test still fail. Please refer to the attached java file. Test output: java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:45470" "connect,resolve") at java.util.concurrent.CompletableFuture.reportGet(java.base@9-internal/CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get(java.base@9-internal/CompletableFuture.java:1999) at WSPermissionTest.lambda$urlPermissionTest$6(WSPermissionTest.java:196) ... 11 more Caused by: java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:45470" "connect,resolve") at java.security.AccessControlContext.checkPermission(java.base@9-internal/AccessControlContext.java:468) at java.security.AccessController.checkPermission(java.base@9-internal/AccessController.java:894) at java.lang.SecurityManager.checkPermission(java.base@9-internal/SecurityManager.java:548) at java.lang.SecurityManager.checkConnect(java.base@9-internal/SecurityManager.java:1050) at sun.nio.ch.SocketChannelImpl.connect(java.base@9-internal/SocketChannelImpl.java:627) at java.net.http.PlainHttpConnection.connect(java.httpclient@9-internal/PlainHttpConnection.java:122) at java.net.http.Http1Exchange.sendHeadersOnly(java.httpclient@9-internal/Http1Exchange.java:133) at java.net.http.ExchangeImpl.sendRequest(java.httpclient@9-internal/ExchangeImpl.java:176) at java.net.http.ExchangeImpl.lambda$sendRequestAsync$1(java.httpclient@9-internal/ExchangeImpl.java:184) at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@9-internal/ThreadPoolExecutor.java:1158) at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@9-internal/ThreadPoolExecutor.java:632) at java.lang.Thread.run(java.base@9-internal/Thread.java:843) at jdk.internal.misc.InnocuousThread.run(java.base@9-internal/InnocuousThread.java:122)

    JDK Bug System | 5 months ago | Felix Yang
    java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:45470" "connect,resolve") at java.util.concurrent.CompletableFuture.reportGet(java.base@9-internal/CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get(java.base@9-internal/CompletableFuture.java:1999)
  2. 0

    This can be reproduced with following WebSocket scenario. But I don't think it is only a WebSocket problem. It looks to be a problem in current java.net.http.*HttpConnection implementation //A simple test to reproduce the problem public class WSReconnectTest { public static void main(String[] args) throws Exception { String wsURL = "your_ws_endpoint"; connect(wsURL); connect(wsURL); } /** * Tests send and receive plain text messages with different length. * @throws Exception */ static void connect(String url) throws Exception { Listener l = new Listener() { @Override public void onError(WebSocket webSocket, Throwable error) { System.err.println(error); error.printStackTrace(); } }; URI uri = new URI(url); WebSocket ws= WebSocket.newBuilder(uri, l).buildAsync().get(); ws.sendClose().get(); } } It will fail immediately at the second connect attempt. Please refer to the test output:----------System.err:(24/1946)---------- java.util.concurrent.ExecutionException: java.io.IOException: Connection closed at java.util.concurrent.CompletableFuture.reportGet(java.base@9-internal/CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get(java.base@9-internal/CompletableFuture.java:1999) at WSReconnectTest.connect(WSReconnectTest.java:58) at WSReconnectTest.main(WSReconnectTest.java:42) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-internal/Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-internal/NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-internal/DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(java.base@9-internal/Method.java:535) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110) at java.lang.Thread.run(java.base@9-internal/Thread.java:843) Caused by: java.io.IOException: Connection closed at java.net.http.Http1Response.readHeaders(java.httpclient@9-internal/Http1Response.java:72) at java.net.http.Http1Exchange.lambda$getResponseAsyncImpl$0(java.httpclient@9-internal/Http1Exchange.java:190) at java.net.http.Utils.lambda$singleThreadExecutor$5(java.httpclient@9-internal/Utils.java:495) at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@9-internal/ThreadPoolExecutor.java:1158) at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@9-internal/ThreadPoolExecutor.java:632) at java.lang.Thread.run(java.base@9-internal/Thread.java:843) at jdk.internal.misc.InnocuousThread.run(java.base@9-internal/InnocuousThread.java:122) "java.io.IOException: Connection closed" is the cause of failing to reconnect. According java.net.http.HttpConnection.getConnectionImpl(xxx), it will try to get pooled connection if exists. But the pooled connection never got removed during closing connection. So the next attempt to connect will get the same connection which has been closed.

    JDK Bug System | 5 months ago | Felix Yang
    java.util.concurrent.ExecutionException: java.io.IOException: Connection closed at java.util.concurrent.CompletableFuture.reportGet(java.base@9-internal/CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get(java.base@9-internal/CompletableFuture.java:1999)
  3. 0

    Exception in ServerCallable.call(): java.lang.RuntimeException: Too much loops to produce handshake packets at DTLSOverDatagram.handshake(DTLSOverDatagram.java:154) at DTLSOverDatagram.doServerSide(DTLSOverDatagram.java:98) at DTLSOverDatagram$ServerCallable.call(DTLSOverDatagram.java:647) at DTLSOverDatagram$ServerCallable.call(DTLSOverDatagram.java:630) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1161) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:844) Client: Warning: java.net.SocketTimeoutException: Receive timed out Client: Reproduced 0 packets Client: New handshake status is NEED_UNWRAP Client: Handshake finished, status is NEED_UNWRAP Client: Negotiated protocol is NONE Client: Negotiated cipher suite is SSL_NULL_WITH_NULL_NULL Exception in ClientCallable.call(): java.lang.Exception: Unexpected handshake status NEED_UNWRAP at DTLSOverDatagram.handshake(DTLSOverDatagram.java:289) at DTLSOverDatagram.doClientSide(DTLSOverDatagram.java:117) at DTLSOverDatagram$ClientCallable.call(DTLSOverDatagram.java:685) at DTLSOverDatagram$ClientCallable.call(DTLSOverDatagram.java:668) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1161) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:844) Exception on client side: java.util.concurrent.ExecutionException: java.lang.Exception: Unexpected handshake status NEED_UNWRAP at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at DTLSOverDatagram.runTest(DTLSOverDatagram.java:606) at Reordered.main(Reordered.java:50) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:538) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110) at java.base/java.lang.Thread.run(Thread.java:844) Caused by: java.lang.Exception: Unexpected handshake status NEED_UNWRAP at DTLSOverDatagram.handshake(DTLSOverDatagram.java:289) at DTLSOverDatagram.doClientSide(DTLSOverDatagram.java:117) at DTLSOverDatagram$ClientCallable.call(DTLSOverDatagram.java:685) at DTLSOverDatagram$ClientCallable.call(DTLSOverDatagram.java:668) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1161) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ... 1 more Exception on server side: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Too much loops to produce handshake packets at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at DTLSOverDatagram.runTest(DTLSOverDatagram.java:616) at Reordered.main(Reordered.java:50) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:538) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110) at java.base/java.lang.Thread.run(Thread.java:844) Caused by: java.lang.RuntimeException: Too much loops to produce handshake packets at DTLSOverDatagram.handshake(DTLSOverDatagram.java:154) at DTLSOverDatagram.doServerSide(DTLSOverDatagram.java:98) at DTLSOverDatagram$ServerCallable.call(DTLSOverDatagram.java:647) at DTLSOverDatagram$ServerCallable.call(DTLSOverDatagram.java:630) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1161) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ... 1 more ----------System.err:(14/823)---------- java.lang.RuntimeException: Test failed at DTLSOverDatagram.runTest(DTLSOverDatagram.java:625) at Reordered.main(Reordered.java:50) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:538) at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110) at java.base/java.lang.Thread.run(Thread.java:844)

    JDK Bug System | 1 month ago | John Jiang
    java.util.concurrent.ExecutionException: java.lang.Exception: Unexpected handshake status NEED_UNWRAP at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Applet permissions denied unpredictably

    Oracle Community | 10 years ago | 843807
    java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.util.concurrent.ExecutionException

      java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:45470" "connect,resolve") at java.util.concurrent.CompletableFuture.reportGet(java.base@9-internal/CompletableFuture.java:395) at java.util.concurrent.CompletableFuture.get(java.base@9-internal/CompletableFuture.java:1999)

      at WSPermissionTest.lambda$urlPermissionTest$6()
    2. Unknown
      WSPermissionTest.lambda$urlPermissionTest$6
      1. WSPermissionTest.lambda$urlPermissionTest$6(WSPermissionTest.java:196)
      1 frame