You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/03/15 02:37:57 UTC

logging-log4j2 git commit: No need to call isTraceEnabled() if the message is null. This means the traceEnter() call returned null because isTraceEnabled() returned null.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master b33421521 -> d5f7c94f8


No need to call isTraceEnabled() if the message is null. This means the
traceEnter() call returned null because isTraceEnabled() returned null.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d5f7c94f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d5f7c94f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d5f7c94f

Branch: refs/heads/master
Commit: d5f7c94f89a5492092764e154adabe4aa12e6a29
Parents: b334215
Author: ggregory <gg...@apache.org>
Authored: Mon Mar 14 18:37:55 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Mon Mar 14 18:37:55 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/spi/AbstractLogger.java   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d5f7c94f/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
index b190535..244b8e7 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
@@ -1431,14 +1431,16 @@ public abstract class AbstractLogger implements ExtendedLogger, Serializable {
 
     @Override
     public void traceExit(final EntryMessage message) {
-        if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
+        // If the message is null, traceEnter returned null because flow logging was disabled, we can optimize out calling isEnabled().
+        if (message != null && isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
             logMessage(FQCN, Level.TRACE, EXIT_MARKER, flowMessageFactory.newExitMessage(message), null);
         }
     }
 
     @Override
     public <R> R traceExit(final EntryMessage message, final R result) {
-        if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
+        // If the message is null, traceEnter returned null because flow logging was disabled, we can optimize out calling isEnabled().
+        if (message != null && isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
             logMessage(FQCN, Level.TRACE, EXIT_MARKER, flowMessageFactory.newExitMessage(result, message), null);
         }
         return result;
@@ -1446,7 +1448,8 @@ public abstract class AbstractLogger implements ExtendedLogger, Serializable {
 
     @Override
     public <R> R traceExit(final Message message, final R result) {
-        if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
+        // If the message is null, traceEnter returned null because flow logging was disabled, we can optimize out calling isEnabled().
+        if (message != null && isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
             logMessage(FQCN, Level.TRACE, EXIT_MARKER, flowMessageFactory.newExitMessage(result, message), null);
         }
         return result;