From 2aaa468a22ef8bf58fa4bffa9eabab9df7ecc9b1 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 | 8 +------- 1 file changed, 1 insertion(+), 7 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 c644459c51..c0ab3d3178 100644 --- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java +++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java @@ -98,9 +98,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); @@ -138,11 +138,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,7 +338,6 @@ public final class NativeLibraryLoader { return; } catch (UnsatisfiedLinkError | Exception e) { // Should by pass the UnsatisfiedLinkError here! 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);