Bug 45825

Summary: lack of synchronization in ThrowableInformation
Product: Log4j - Now in Jira Reporter: Tomasz Sadura <borysb>
Component: OtherAssignee: log4j-dev <log4j-dev>
Severity: major    
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Tomasz Sadura 2008-09-17 07:54:10 UTC
Log4j version 1.2.15.
Method getThrowableStrRep in org.apache.log4j.spi.ThrowableInformation should be synchronized in some way. The variable rep can be read by one thread (for example AsynsAppender) in line 72, while another is in line 91 (lines.toArray(rep)). This may cause rep to contain some nulls. It leads to NullPointerException at java.io.Writer.write(Writer.java:140). Stacktrace:

 at java.io.Writer.write(Writer.java:140)   
 at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:48)   
 at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:309)   
 at org.apache.log4j.WriterAppender.append(WriterAppender.java:160)   
 at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)   
 at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)   
 at org.apache.log4j.Category.callAppenders(Category.java:206)   
 at org.apache.log4j.Category.forcedLog(Category.java:391)   
 at org.apache.log4j.Category.info(Category.java:683)
Comment 1 Curt Arnold 2008-09-17 09:12:17 UTC

*** This bug has been marked as a duplicate of bug 44032 ***