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 GitHub
parent de4627852f
commit 70292f6823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,7 +120,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(
@ -586,7 +587,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]));
}