From b1332bf12e75432260dbcdae9dadfe06ef06e969 Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Thu, 14 Sep 2017 22:45:16 -0700 Subject: [PATCH] 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. --- .../main/java/io/netty/util/internal/NativeLibraryLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java index b3cb3b5de9..dc3e359a78 100644 --- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java +++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java @@ -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)