From 5158e3976dcdcb0ed878763ca0fa2014c8f949d4 Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Tue, 23 Feb 2021 02:03:07 -0800 Subject: [PATCH] Less noisy logging in `DnsServerAddressStreamProviders` (#11031) Motivation: It is not uncommon to run Netty on OS X without the specific `MacOSDnsServerAddressStreamProvider`. The current log message is too verbose because it prints a full stack trace on the console while a simple logging message would have been enough. Modifications: - Print a `WARN` message when `MacOSDnsServerAddressStreamProvider` class is not found; - Print a `ERROR` message with a stack trace when the class was found but could not be loaded due to some other reasons; Result: Less noise in logs. --- .../resolver/dns/DnsServerAddressStreamProviders.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddressStreamProviders.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddressStreamProviders.java index f316091b71..8ba95777b8 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddressStreamProviders.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsServerAddressStreamProviders.java @@ -66,10 +66,12 @@ public final class DnsServerAddressStreamProviders { } else { throw (Throwable) maybeProvider; } + } catch (ClassNotFoundException cause) { + LOGGER.warn("Can not find {} in the classpath, fallback to system defaults. This may result in " + + "incorrect DNS resolutions on MacOS.", MACOS_PROVIDER_CLASS_NAME); } catch (Throwable cause) { - LOGGER.warn( - "Unable to load {}, fallback to system defaults. {}", MACOS_PROVIDER_CLASS_NAME, - "This may result in incorrect DNS resolutions on MacOS.", cause); + LOGGER.error("Unable to load {}, fallback to system defaults. This may result in " + + "incorrect DNS resolutions on MacOS.", MACOS_PROVIDER_CLASS_NAME, cause); constructor = null; } }