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) {
|
} 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 {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -137,9 +137,11 @@ public final class NativeLibraryLoader {
|
|||||||
return;
|
return;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
suppressed.add(ex);
|
suppressed.add(ex);
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"{} cannot be loaded from java.library.path, "
|
logger.debug(
|
||||||
+ "now trying export to -Dio.netty.native.workdir: {}", name, WORKDIR, ex);
|
"{} cannot be loaded from java.library.path, "
|
||||||
|
+ "now trying export to -Dio.netty.native.workdir: {}", name, WORKDIR, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String libname = System.mapLibraryName(name);
|
String libname = System.mapLibraryName(name);
|
||||||
|
@ -1163,8 +1163,10 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Throwable cause) {
|
} catch (Throwable cause) {
|
||||||
logger.debug("Unexpected exception while loading class {} classname {}",
|
if (logger.isDebugEnabled()) {
|
||||||
getClass(), classname, cause);
|
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
|
return nameServerCache.mayOverrideNameServers() ? nameServerCache
|
||||||
: DefaultDnsServerAddressStreamProvider.INSTANCE;
|
: DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||||
} catch (Exception e) {
|
} 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;
|
return DefaultDnsServerAddressStreamProvider.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,8 +256,10 @@ public final class UnixResolverDnsServerAddressStreamProvider implements DnsServ
|
|||||||
DnsServerAddresses existingAddresses = domainToNameServerStreamMap.put(domainName, addresses);
|
DnsServerAddresses existingAddresses = domainToNameServerStreamMap.put(domainName, addresses);
|
||||||
if (existingAddresses != null) {
|
if (existingAddresses != null) {
|
||||||
domainToNameServerStreamMap.put(domainName, existingAddresses);
|
domainToNameServerStreamMap.put(domainName, existingAddresses);
|
||||||
logger.debug("Domain name {} already maps to addresses {} so new addresses {} will be discarded",
|
if (logger.isDebugEnabled()) {
|
||||||
domainName, existingAddresses, addresses);
|
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 {
|
try {
|
||||||
m = handlerType.getMethod(methodName, paramTypes);
|
m = handlerType.getMethod(methodName, paramTypes);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Class {} missing method {}, assume we can not skip execution", handlerType, methodName, e);
|
logger.debug(
|
||||||
|
"Class {} missing method {}, assume we can not skip execution", handlerType, methodName, e);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m != null && m.isAnnotationPresent(Skip.class);
|
return m != null && m.isAnnotationPresent(Skip.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user