Do not log CNFE when tcnative is not in classpath
Motivation: When a user deliberatively omitted netty-tcnative from classpath, he or she will see an ugly stack trace of ClassNotFoundException. Modifications: Log more briefly when netty-tcnative is not in classpath. Result: Better-looking log at DEBUG level
This commit is contained in:
parent
851ca79ea6
commit
f0a4802d1f
@ -41,6 +41,19 @@ public final class OpenSsl {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
Throwable cause = null;
|
Throwable cause = null;
|
||||||
|
|
||||||
|
// Test if netty-tcnative is in the classpath first.
|
||||||
|
try {
|
||||||
|
Class.forName("org.apache.tomcat.jni.SSL", false, OpenSsl.class.getClassLoader());
|
||||||
|
} catch (ClassNotFoundException t) {
|
||||||
|
cause = t;
|
||||||
|
logger.debug(
|
||||||
|
"netty-tcnative not in the classpath; " +
|
||||||
|
OpenSslEngine.class.getSimpleName() + " will be unavailable.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If in the classpath, try to load the native library and initialize netty-tcnative.
|
||||||
|
if (cause == null) {
|
||||||
try {
|
try {
|
||||||
NativeLibraryLoader.load("netty-tcnative", SSL.class.getClassLoader());
|
NativeLibraryLoader.load("netty-tcnative", SSL.class.getClassLoader());
|
||||||
Library.initialize("provided");
|
Library.initialize("provided");
|
||||||
@ -51,6 +64,8 @@ public final class OpenSsl {
|
|||||||
"Failed to load netty-tcnative; " +
|
"Failed to load netty-tcnative; " +
|
||||||
OpenSslEngine.class.getSimpleName() + " will be unavailable.", t);
|
OpenSslEngine.class.getSimpleName() + " will be unavailable.", t);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UNAVAILABILITY_CAUSE = cause;
|
UNAVAILABILITY_CAUSE = cause;
|
||||||
|
|
||||||
if (cause == null) {
|
if (cause == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user