Bug 43599

Summary: AsyncAppender fails on changing MessageObjects
Product: Log4j - Now in Jira Reporter: Horst Scheruga <horst>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: All   
OS: other   

Description Horst Scheruga 2007-10-11 06:02:43 UTC
If I use an AsyncAppender to log a message object that is changed after the call
of the logging method, the logging will sometime show up the value changed
afterwards.


Example

  StringBuffer buffer = new StringBuffer("Hello world");

  Logger.getLogger("sample").debug(buffer);

  buffer.setLength(0);
  buffer.append("changed message");

If an AsyncAppender is used for logging this,
it may log on of the three values:
  "Hello world"
  ""
  "changed message"
Comment 1 Curt Arnold 2007-10-22 14:10:32 UTC
Committed test and fix in rev 587252.

From reviewing the code, it appears that this bug has been in the log4j codebase for an extended time 
and was preserved (not introduced) in the AsyncAppender rewrite released in log4j 1.2.14.  Added a call to 
getRenderedMessage() which will capture the value of the message object before placing the LoggingEvent 
on the queue.