From c3c05e85701c60c46303f1f4c3b6c65c64a56ad7 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 9 Apr 2019 08:31:39 +0200 Subject: [PATCH] Fix NPE in OpenSslPrivateKeyMethodTest.destroy() when BoringSSL is not used Motivation: 4079189f6bd3e2c26ec443f24a204ffe144f1ada introduced OpenSslPrivateKeyMethodTest which will only be run when BoringSSL is used. As the assumeTrue(...) also guards the init of the static fields we need to ensure we only try to destroy these if BoringSSL is used as otherwise it will produce a NPE. Modifications: Check if BoringSSL is used before trying to destroy the resources. Result: No more NPE when BoringSSL is not used. --- .../io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java b/handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java index 1a7b49f6c2..813a67adc3 100644 --- a/handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java @@ -106,9 +106,11 @@ public class OpenSslPrivateKeyMethodTest { @AfterClass public static void destroy() { - GROUP.shutdownGracefully(); - CERT.delete(); - EXECUTOR.shutdown(); + if (OpenSsl.isBoringSSL()) { + GROUP.shutdownGracefully(); + CERT.delete(); + EXECUTOR.shutdown(); + } } private final boolean delegate;