Take the architecture into account when loading netty-tcnative

Motivation:

We should ensure we only try to load the netty-tcnative version that was compiled for the architecture we are using.

Modifications:

Include architecture into native lib name.

Result:

Only load native lib if the architecture is supported.
This commit is contained in:
Norman Maurer 2017-10-24 19:52:55 +02:00
parent cdb2a27857
commit ad1f0d46b3

View File

@ -406,15 +406,17 @@ public final class OpenSsl {
String arch = PlatformDependent.normalizedArch();
Set<String> libNames = new LinkedHashSet<String>(4);
String staticLibName = "netty_tcnative";
// First, try loading the platform-specific library. Platform-specific
// libraries will be available if using a tcnative uber jar.
libNames.add("netty_tcnative_" + os + '_' + arch);
libNames.add(staticLibName + "_" + os + '_' + arch);
if ("linux".equalsIgnoreCase(os)) {
// Fedora SSL lib so naming (libssl.so.10 vs libssl.so.1.0.0)..
libNames.add("netty_tcnative_" + os + '_' + arch + "_fedora");
libNames.add(staticLibName + "_" + os + '_' + arch + "_fedora");
}
// finally the default library.
libNames.add("netty_tcnative");
libNames.add(staticLibName + "_" + arch);
libNames.add(staticLibName);
NativeLibraryLoader.loadFirstAvailable(SSL.class.getClassLoader(),
libNames.toArray(new String[libNames.size()]));