From 9c5dbfd1b629ffd0a6617095f2210522e74ad46d Mon Sep 17 00:00:00 2001 From: skyguard1 Date: Thu, 6 Aug 2020 15:02:37 +0800 Subject: [PATCH] Replace Class.getClassLoader with io.netty.util.internal.PlatformDependent.getClassLoader in Openssl (#10454) Motivation: Replace Class.getClassLoader with io.netty.util.internal.PlatformDependent.getClassLoader in Openssl so it also works when a SecurityManager is in place Modification: Replace Class.getClassLoader with io.netty.util.internal.PlatformDependent.getClassLoader in Openssl Result: No issues when a SecurityManager is in place --- handler/src/main/java/io/netty/handler/ssl/OpenSsl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java b/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java index fe1956b953..93125d8b73 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java @@ -119,7 +119,8 @@ public final class OpenSsl { } else { // Test if netty-tcnative is in the classpath first. try { - Class.forName("io.netty.internal.tcnative.SSLContext", false, OpenSsl.class.getClassLoader()); + Class.forName("io.netty.internal.tcnative.SSLContext", false, + PlatformDependent.getClassLoader(OpenSsl.class)); } catch (ClassNotFoundException t) { cause = t; logger.debug( @@ -556,7 +557,7 @@ public final class OpenSsl { libNames.add(staticLibName + "_" + arch); libNames.add(staticLibName); - NativeLibraryLoader.loadFirstAvailable(SSLContext.class.getClassLoader(), + NativeLibraryLoader.loadFirstAvailable(PlatformDependent.getClassLoader(SSLContext.class), libNames.toArray(new String[0])); }