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
This commit is contained in:
skyguard1 2020-08-06 15:02:37 +08:00 committed by Norman Maurer
parent 10354b62c8
commit 9c5dbfd1b6

View File

@ -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]));
}