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/03/08 15:39:45 UTC

logging-log4j2 git commit: LOG4J2-1296 SmtpManager: when storing a Log4jLogEvent in a buffer, ensure that the Message is immutable

Repository: logging-log4j2
Updated Branches:
  refs/heads/master e039c72c8 -> f1e506389


LOG4J2-1296 SmtpManager: when storing a Log4jLogEvent in a buffer, ensure that the Message is immutable


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

Branch: refs/heads/master
Commit: f1e50638916325f52b0860583e68e79f62b3601a
Parents: e039c72
Author: rpopma <rp...@apache.org>
Authored: Wed Mar 9 01:39:38 2016 +1100
Committer: rpopma <rp...@apache.org>
Committed: Wed Mar 9 01:39:38 2016 +1100

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


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f1e50638/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 54bbc93..b101b2d 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
@@ -42,11 +42,13 @@ import org.apache.logging.log4j.core.LogEvent;
 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.layout.AbstractStringLayout.Serializer;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 import org.apache.logging.log4j.core.util.CyclicBuffer;
 import org.apache.logging.log4j.core.util.NameUtil;
 import org.apache.logging.log4j.core.util.NetUtils;
+import org.apache.logging.log4j.message.ReusableMessage;
 import org.apache.logging.log4j.util.PropertiesUtil;
 import org.apache.logging.log4j.util.Strings;
 
@@ -57,7 +59,7 @@ public class SmtpManager extends AbstractManager {
     private static final SMTPManagerFactory FACTORY = new SMTPManagerFactory();
 
     private final Session session;
-    
+
     private final CyclicBuffer<LogEvent> buffer;
 
     private volatile MimeMessage message;
@@ -82,6 +84,9 @@ public class SmtpManager extends AbstractManager {
     }
 
     public void add(final LogEvent event) {
+        if (event instanceof Log4jLogEvent && event.getMessage() instanceof ReusableMessage) {
+            ((Log4jLogEvent) event).makeMessageImmutable();
+        }
         buffer.add(event);
     }