That's what I thought but unfortunately it doesn't work that way: the deserialization itself fails with a ClassDefNotFound... So the receiver just gets that error. I thought the error would occur when receiver accessed the throwable but it is before that.
I've added junit tests for this now. You can try removing the transient keyword to see what happens. The junit tests look a bit awkward as it involves serializing an event and then deleting the exception class that was serialized before unserializing. It might be possible to automate this but I just did it manually & commented out the exception before deserialization. Sent from my iPhone > On 2014/05/25, at 6:07, Gary Gregory <[email protected]> wrote: > > 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 > > > -------- Original message -------- > From: [email protected] > Date:05/24/2014 10:42 (GMT-05:00) > To: [email protected] > Subject: svn commit: r1597311 - > /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java > > 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); > } > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
