Add log level check simply before logging. (#10080)
Motivation: In general, we will close the debug log in a product environment. However, logging without external level check may still affect performance as varargs will need to allocate an array. Modification: Add log level check simply before logging. Result: Improve performance slightly in a product environment.
This commit is contained in:
parent
65b1713ce7
commit
15fa45a84b
@ -291,7 +291,10 @@ public final class NetUtil {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}", file, somaxconn, e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}",
|
||||
file, somaxconn, e);
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
|
@ -137,9 +137,11 @@ public final class NativeLibraryLoader {
|
||||
return;
|
||||
} catch (Throwable ex) {
|
||||
suppressed.add(ex);
|
||||
logger.debug(
|
||||
"{} cannot be loaded from java.library.path, "
|
||||
+ "now trying export to -Dio.netty.native.workdir: {}", name, WORKDIR, 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);
|
||||
|
@ -1163,8 +1163,10 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable cause) {
|
||||
logger.debug("Unexpected exception while loading class {} classname {}",
|
||||
getClass(), classname, cause);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Unexpected exception while loading class {} classname {}",
|
||||
getClass(), classname, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,9 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
||||
return nameServerCache.mayOverrideNameServers() ? nameServerCache
|
||||
: DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||
} catch (Exception e) {
|
||||
logger.debug("failed to parse {} and/or {}", ETC_RESOLV_CONF_FILE, ETC_RESOLVER_DIR, e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("failed to parse {} and/or {}", ETC_RESOLV_CONF_FILE, ETC_RESOLVER_DIR, e);
|
||||
}
|
||||
return DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -254,8 +256,10 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
||||
DnsServerAddresses existingAddresses = domainToNameServerStreamMap.put(domainName, addresses);
|
||||
if (existingAddresses != null) {
|
||||
domainToNameServerStreamMap.put(domainName, existingAddresses);
|
||||
logger.debug("Domain name {} already maps to addresses {} so new addresses {} will be discarded",
|
||||
domainName, existingAddresses, addresses);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Domain name {} already maps to addresses {} so new addresses {} will be discarded",
|
||||
domainName, existingAddresses, addresses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,8 +173,10 @@ final class ChannelHandlerMask {
|
||||
try {
|
||||
m = handlerType.getMethod(methodName, paramTypes);
|
||||
} catch (NoSuchMethodException e) {
|
||||
logger.debug(
|
||||
"Class {} missing method {}, assume we can not skip execution", handlerType, methodName, e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"Class {} missing method {}, assume we can not skip execution", handlerType, methodName, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return m != null && m.isAnnotationPresent(Skip.class);
|
||||
|
Loading…
Reference in New Issue
Block a user