From 4d43f16bb9ccb10f575dcae432d25f6796b9886c Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sat, 16 Jan 2021 09:56:44 +0100 Subject: [PATCH] Make native loading logging less confusing (#10944) Motivation: We produced a lot of noise during loading native libraries as we always included the stacktrace if we could not load by one mechanism. We should better just not include the stacktrace in the debugging logging if one mechanism fails. We will log all the stacks anyway when all of the mechanisms fail. Modifications: Make logging less aggressive Result: Less confusing behaviour for the end-user --- .../java/io/netty/util/internal/NativeLibraryLoader.java | 9 +-------- 1 file changed, 1 insertion(+), 8 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 ed52e612d5..dc99f1b95b 100644 --- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java +++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java @@ -97,9 +97,9 @@ public final class NativeLibraryLoader { return; } catch (Throwable t) { suppressed.add(t); - logger.debug("Unable to load the library '{}', trying next name...", name, t); } } + IllegalArgumentException iae = new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names)); ThrowableUtil.addSuppressedAndClear(iae, suppressed); @@ -137,11 +137,6 @@ public final class NativeLibraryLoader { return; } catch (Throwable ex) { suppressed.add(ex); - if (logger.isDebugEnabled()) { - logger.debug( - "{} cannot be loaded from java.library.path, " - + "now trying export to -Dio.netty.native.workdir: {}", name, WORKDIR, ex); - } } String libname = System.mapLibraryName(name); @@ -343,10 +338,8 @@ public final class NativeLibraryLoader { return; } catch (UnsatisfiedLinkError e) { // Should by pass the UnsatisfiedLinkError here! suppressed = e; - logger.debug("Unable to load the library '{}', trying other loading mechanism.", name, e); } catch (Exception e) { suppressed = e; - 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);