GeezerVison is showing github.com — Await termination of SslHandler executor (#16138) · netty/netty@ba00ff8
File treeExpand file treeCollapse file tree Open diff view settings handler/src/test/java/io/netty/handler/ssl testsuite/src/main/java/io/netty/testsuite/transport/socket transport-blockhound-tests/src/test/java/io/netty/util/internal
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -223,16 +223,17 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) | 223 | 223 | } | 224 | 224 | } finally { | 225 | 225 | server.close().sync(); | | 226 | + | | 227 | + if (executorService != null) { | | 228 | + executorService.shutdown(); | | 229 | + assertTrue(executorService.awaitTermination(5, TimeUnit.SECONDS)); | | 230 | + } | 226 | 231 | } | 227 | 232 | } finally { | 228 | 233 | ReferenceCountUtil.release(sslClientContext); | 229 | 234 | } | 230 | 235 | } finally { | 231 | 236 | ReferenceCountUtil.release(sslServerContext); | 232 | | - | 233 | | - if (executorService != null) { | 234 | | - executorService.shutdown(); | 235 | | - } | 236 | 237 | } | 237 | 238 | } | 238 | 239 |
| |
Collapse file Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/DelayingExecutor.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,7 +42,8 @@ public void execute(Runnable command) { | 42 | 42 | PlatformDependent.threadLocalRandom().nextInt(100), TimeUnit.MILLISECONDS); | 43 | 43 | } | 44 | 44 |
| 45 | | - void shutdown() { | | 45 | + boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException { | 46 | 46 | service.shutdown(); | | 47 | + return service.awaitTermination(timeout, unit); | 47 | 48 | } | 48 | 49 | } |
Collapse file Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 58 | 58 | import java.util.Collections; | 59 | 59 | import java.util.List; | 60 | 60 | import java.util.concurrent.Executor; | 61 | | -import java.util.concurrent.ExecutorService; | 62 | | -import java.util.concurrent.Executors; | 63 | 61 | import java.util.concurrent.ThreadFactory; | 64 | 62 | import java.util.concurrent.TimeUnit; | 65 | 63 | import java.util.concurrent.atomic.AtomicBoolean; | @@ -110,11 +108,11 @@ public Thread newThread(Runnable r) { | 110 | 108 | } | 111 | 109 |
| 112 | 110 | @AfterAll | 113 | | - public static void destroy() { | | 111 | + public static void destroy() throws InterruptedException { | 114 | 112 | if (OpenSsl.isBoringSSL() || OpenSsl.isAWSLC()) { | 115 | 113 | GROUP.shutdownGracefully(); | 116 | 114 | CERT.delete(); | 117 | | - EXECUTOR.shutdown(); | | 115 | + assertTrue(EXECUTOR.shutdownAndAwaitTermination(5, TimeUnit.SECONDS)); | 118 | 116 | } | 119 | 117 | } | 120 | 118 |
| |
Collapse file Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -547,7 +547,7 @@ public void tearDown() throws InterruptedException { | 547 | 547 | if (clientGroupShutdownFuture != null) { | 548 | 548 | clientGroupShutdownFuture.sync(); | 549 | 549 | } | 550 | | - delegatingExecutor.shutdown(); | | 550 | + assertTrue(delegatingExecutor.shutdownAndAwaitTermination(5, TimeUnit.SECONDS)); | 551 | 551 | serverException = null; | 552 | 552 | clientException = null; | 553 | 553 | } | |
Collapse file Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1000,7 +1000,7 @@ public void testHandshakeWithExecutorJDK() throws Throwable { | 1000 | 1000 | try { | 1001 | 1001 | testHandshakeWithExecutor(executorService, SslProvider.JDK, false); | 1002 | 1002 | } finally { | 1003 | | - executorService.shutdown(); | | 1003 | + assertTrue(executorService.shutdownAndAwaitTermination(5, TimeUnit.SECONDS)); | 1004 | 1004 | } | 1005 | 1005 | } | 1006 | 1006 |
| @@ -1029,7 +1029,7 @@ public void testHandshakeWithExecutorOpenSsl() throws Throwable { | 1029 | 1029 | try { | 1030 | 1030 | testHandshakeWithExecutor(executorService, SslProvider.OPENSSL, false); | 1031 | 1031 | } finally { | 1032 | | - executorService.shutdown(); | | 1032 | + assertTrue(executorService.shutdownAndAwaitTermination(5, TimeUnit.SECONDS)); | 1033 | 1033 | } | 1034 | 1034 | } | 1035 | 1035 |
| @@ -1054,7 +1054,7 @@ public void testHandshakeMTLSWithExecutorJDK() throws Throwable { | 1054 | 1054 | try { | 1055 | 1055 | testHandshakeWithExecutor(executorService, SslProvider.JDK, true); | 1056 | 1056 | } finally { | 1057 | | - executorService.shutdown(); | | 1057 | + assertTrue(executorService.shutdownAndAwaitTermination(5, TimeUnit.SECONDS)); | 1058 | 1058 | } | 1059 | 1059 | } | 1060 | 1060 |
| @@ -1083,7 +1083,7 @@ public void testHandshakeMTLSWithExecutorOpenSsl() throws Throwable { | 1083 | 1083 | try { | 1084 | 1084 | testHandshakeWithExecutor(executorService, SslProvider.OPENSSL, true); | 1085 | 1085 | } finally { | 1086 | | - executorService.shutdown(); | | 1086 | + assertTrue(executorService.shutdownAndAwaitTermination(5, TimeUnit.SECONDS)); | 1087 | 1087 | } | 1088 | 1088 | } | 1089 | 1089 |
| |
Collapse file Copy file name to clipboardExpand all lines: testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslClientRenegotiateTest.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -206,6 +206,7 @@ public void initChannel(Channel sch) throws Exception { | 206 | 206 | } finally { | 207 | 207 | if (executorService != null) { | 208 | 208 | executorService.shutdown(); | | 209 | + assertTrue(executorService.awaitTermination(5, TimeUnit.SECONDS)); | 209 | 210 | } | 210 | 211 | } | 211 | 212 | } | |
Collapse file Copy file name to clipboardExpand all lines: testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -381,6 +381,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { | 381 | 381 | clientChannel.close().awaitUninterruptibly(); | 382 | 382 | sc.close().awaitUninterruptibly(); | 383 | 383 | delegatedTaskExecutor.shutdown(); | | 384 | + assertTrue(delegatedTaskExecutor.awaitTermination(5, TimeUnit.SECONDS)); | 384 | 385 |
| 385 | 386 | if (serverException.get() != null && !(serverException.get() instanceof IOException)) { | 386 | 387 | throw serverException.get(); | |
Collapse file Copy file name to clipboardExpand all lines: testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslGreetingTest.java +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 58 | 58 |
| 59 | 59 | import static org.junit.jupiter.api.Assertions.assertEquals; | 60 | 60 | import static org.junit.jupiter.api.Assertions.assertFalse; | | 61 | +import static org.junit.jupiter.api.Assertions.assertTrue; | 61 | 62 | import static org.junit.jupiter.api.Assertions.fail; | 62 | 63 |
| 63 | 64 | public class SocketSslGreetingTest extends AbstractSocketTest { | @@ -179,6 +180,7 @@ public void initChannel(Channel sch) throws Exception { | 179 | 180 | } finally { | 180 | 181 | if (executorService != null) { | 181 | 182 | executorService.shutdown(); | | 183 | + assertTrue(executorService.awaitTermination(5, TimeUnit.SECONDS)); | 182 | 184 | } | 183 | 185 | } | 184 | 186 | } | |
Collapse file Copy file name to clipboardExpand all lines: transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -250,6 +250,7 @@ public void testHandshakeWithExecutor() throws Exception { | 250 | 250 | testHandshakeWithExecutor(executorService, "TLSv1.2"); | 251 | 251 | } finally { | 252 | 252 | executorService.shutdown(); | | 253 | + assertTrue(executorService.awaitTermination(5, TimeUnit.SECONDS)); | 253 | 254 | } | 254 | 255 | } | 255 | 256 |
| @@ -261,6 +262,7 @@ public void testHandshakeWithExecutorTLSv13() throws Exception { | 261 | 262 | testHandshakeWithExecutor(executorService, "TLSv1.3"); | 262 | 263 | } finally { | 263 | 264 | executorService.shutdown(); | | 265 | + assertTrue(executorService.awaitTermination(5, TimeUnit.SECONDS)); | 264 | 266 | } | 265 | 267 | } | 266 | 268 |
| |
|