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.
This commit is contained in:
Idel Pivnitskiy 2021-02-23 02:03:07 -08:00 committed by GitHub
parent a0b1984c50
commit 5158e3976d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
}