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 GitHub
parent 660759b997
commit b892722efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);