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
3537dc79b9
commit
118e1c66dc
@ -289,7 +289,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 {
|
||||
|
@ -138,10 +138,12 @@ 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);
|
||||
String path = NATIVE_RESOURCE_HOME + libname;
|
||||
|
@ -1167,11 +1167,13 @@ public class SslHandler extends ByteToMessageDecoder {
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable cause) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Unexpected exception while loading class {} classname {}",
|
||||
getClass(), classname, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -72,7 +72,9 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
||||
return nameServerCache.mayOverrideNameServers() ? nameServerCache
|
||||
: DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||
} catch (Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("failed to parse {} and/or {}", ETC_RESOLV_CONF_FILE, ETC_RESOLVER_DIR, e);
|
||||
}
|
||||
return DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -256,10 +258,12 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
||||
DnsServerAddresses existingAddresses = domainToNameServerStreamMap.put(domainName, addresses);
|
||||
if (existingAddresses != null) {
|
||||
domainToNameServerStreamMap.put(domainName, existingAddresses);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Domain name {} already maps to addresses {} so new addresses {} will be discarded",
|
||||
domainName, existingAddresses, addresses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a file of the format <a href="https://linux.die.net/man/5/resolver">/etc/resolv.conf</a> and return the
|
||||
|
@ -175,8 +175,10 @@ final class ChannelHandlerMask {
|
||||
try {
|
||||
m = handlerType.getMethod(methodName, paramTypes);
|
||||
} catch (NoSuchMethodException 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