That does not seem quite right to me. Why not let the throwable be serialized 
and let the receiving end decides whether or not it should catch the error if 
the throwable class is not present. Then this leaves the opportunity to the 
receiver to use the throwable if present otherwise it can use the proxy. This 
may require some smarter deser on our part to allow a valid throwable vs 
catching an absent one and letting the instance variable be null.

Gary

<div>-------- Original message --------</div><div>From: [email protected] 
</div><div>Date:05/24/2014  10:42  (GMT-05:00) </div><div>To: 
[email protected] </div><div>Subject: svn commit: r1597311 -
  
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
 </div><div>
</div>Author: rpopma
Date: Sat May 24 14:42:00 2014
New Revision: 1597311

URL: http://svn.apache.org/r1597311
Log:
additional fix for LOG4J2-250: made Throwable field transient to avoid 
regression on LOG4J2-542

Modified:
    
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java

Modified: 
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?rev=1597311&r1=1597310&r2=1597311&view=diff
==============================================================================
--- 
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
 (original)
+++ 
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
 Sat May 24 14:42:00 2014
@@ -49,7 +49,7 @@ public class Log4jLogEvent implements Lo
     private final String loggerName;
     private final Message message;
     private final long timeMillis;
-    private final Throwable thrown;
+    private transient final Throwable thrown;
     private ThrowableProxy thrownProxy;
     private final Map<String, String> contextMap;
     private final ThreadContext.ContextStack contextStack;
@@ -367,11 +367,13 @@ public class Log4jLogEvent implements Lo
      * @return a LogEventProxy.
      */
     protected Object writeReplace() {
+        getThrownProxy(); // ensure ThrowableProxy is initialized
         return new LogEventProxy(this, this.includeLocation);
     }

     public static Serializable serialize(final Log4jLogEvent event,
             final boolean includeLocation) {
+        event.getThrownProxy(); // ensure ThrowableProxy is initialized
         return new LogEventProxy(event, includeLocation);
     }



Reply via email to