NativeLibraryLoader logging clarify

Motivation:
NativeLibraryLoader may only log a debug statement if the library is successfully loaded from java.library.path, but will log failure statements the if load for java.library.path fails which can mislead users to believe the load actually failed when it may have succeeded.

Modifications:
- Always load a debug statement when a library was successfully loaded

Result:
NativeLibraryLoader log statements more clear.
This commit is contained in:
Scott Mitchell 2017-09-14 22:45:16 -07:00
parent 14189140a0
commit b1332bf12e

View File

@ -79,7 +79,6 @@ public final class NativeLibraryLoader {
for (String name : names) {
try {
load(name, loader);
logger.debug("Successfully loaded the library: {}", name);
return;
} catch (Throwable t) {
logger.debug("Unable to load the library '{}', trying next name...", name, t);
@ -116,7 +115,6 @@ public final class NativeLibraryLoader {
try {
// first try to load from java.library.path
loadLibrary(loader, name, false);
logger.debug("{} was loaded from java.libary.path", name);
return;
} catch (Throwable ex) {
logger.debug(
@ -200,6 +198,7 @@ public final class NativeLibraryLoader {
// Make sure the helper is belong to the target ClassLoader.
final Class<?> newHelper = tryToLoadClass(loader, NativeLibraryUtil.class);
loadLibraryByHelper(newHelper, name, absolute);
logger.debug("Successfully loaded the library {}", name);
return;
} catch (UnsatisfiedLinkError e) { // Should by pass the UnsatisfiedLinkError here!
logger.debug("Unable to load the library '{}', trying other loading mechanism.", name, e);
@ -207,6 +206,7 @@ public final class NativeLibraryLoader {
logger.debug("Unable to load the library '{}', trying other loading mechanism.", name, e);
}
NativeLibraryUtil.loadLibrary(name, absolute); // Fallback to local helper class.
logger.debug("Successfully loaded the library {}", name);
}
private static void loadLibraryByHelper(final Class<?> helper, final String name, final boolean absolute)