Add a log level check simply before logging. (#10093)

Motivation:

ThrowableUtil.stackTraceToString is an expensive method call. So I think a log level check before this logging statement is quite needed especially in a environment with the warning log disabled.

Modification:

Add log level check simply before logging.

Result:

Improve performance in a environment with the warning log disabled.
This commit is contained in:
feijermu 2020-03-09 15:47:53 +08:00 committed by Norman Maurer
parent dddde43dcf
commit f07115c2a6

View File

@ -65,7 +65,7 @@ public final class PromiseNotificationUtil {
Throwable err = p.cause();
if (err == null) {
logger.warn("Failed to mark a promise as failure because it has succeeded already: {}", p, cause);
} else {
} else if (logger.isWarnEnabled()) {
logger.warn(
"Failed to mark a promise as failure because it has failed already: {}, unnotified cause: {}",
p, ThrowableUtil.stackTraceToString(err), cause);