You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/04/16 15:04:18 UTC

logging-log4j2 git commit: LOG4J2-1334 SmtpManager must store snapshot of MutableLogEvent in cyclic buffer, not the MutableEvent itself

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 328a8bf8f -> e323868b0


LOG4J2-1334 SmtpManager must store snapshot of MutableLogEvent in cyclic buffer, not the MutableEvent itself


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

Branch: refs/heads/master
Commit: e323868b06f16b7f2a117cdc216b688b1cd07e0e
Parents: 328a8bf
Author: rpopma <rp...@apache.org>
Authored: Sat Apr 16 22:04:22 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Apr 16 22:04:22 2016 +0900

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/net/SmtpManager.java     | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e323868b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
index b101b2d..ab1d5c7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SmtpManager.java
@@ -43,6 +43,7 @@ import org.apache.logging.log4j.core.appender.AbstractManager;
 import org.apache.logging.log4j.core.appender.ManagerFactory;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.core.impl.MutableLogEvent;
 import org.apache.logging.log4j.core.layout.AbstractStringLayout.Serializer;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 import org.apache.logging.log4j.core.util.CyclicBuffer;
@@ -83,9 +84,11 @@ public class SmtpManager extends AbstractManager {
         this.buffer = new CyclicBuffer<>(LogEvent.class, data.numElements);
     }
 
-    public void add(final LogEvent event) {
+    public void add(LogEvent event) {
         if (event instanceof Log4jLogEvent && event.getMessage() instanceof ReusableMessage) {
             ((Log4jLogEvent) event).makeMessageImmutable();
+        } else if (event instanceof MutableLogEvent) {
+            event = Log4jLogEvent.deserialize(Log4jLogEvent.serialize(event, event.isIncludeLocation()));
         }
         buffer.add(event);
     }