Bug 35324

Summary: Stacktrace may choke on null fields, as org.apache.log4j.spi.ThrowableInformation.VectorWriter.println(null) will bomb
Product: Log4j - Now in Jira Reporter: Reiner Saddey <rws2>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: normal CC: komes_s
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 40951    

Description Reiner Saddey 2005-06-11 00:11:05 UTC
VectorWriter extends java.io.PrintWriter but it does not suppply its forgiving 
services when trying to println(null). Each of Sun's implementations of println
(Object) is capable of handling the singular case of Object==null gracefully, 
but ThrowableInformation.VectorWriter does not, which effectively breaks custom 
made printStackTrace methods at the very instant, when the stack trace is to be 
output to a logger.

In detail, org.apache.log4j.spi.ThrowableInformation.VectorWriter.println
(Object) looks as follows:

  public void println(Object o) {      
    v.addElement(o.toString());
  }

whilst it might preferrably be:

  public void println(Object o) {      
    v.addElement(String.valueOf(o));  
  }
Comment 1 Yoav Shapira 2005-07-30 22:51:31 UTC
Good catch and good suggestion: I've applied it to CVS HEAD in time for log4j
1.3-alpha7.
Comment 2 Curt Arnold 2007-02-20 23:24:24 UTC
Reopening for log4j 1.2 branch
Comment 3 Curt Arnold 2007-02-21 08:52:30 UTC
Committed interim fix in rev 510097.  Expect to gut existing implementation in just a few moments.
Comment 4 Curt Arnold 2007-02-21 13:44:17 UTC
Issue mooted by fix for bug 41219.
Comment 5 Jacob Kjome 2007-03-14 21:41:48 UTC
*** Bug 36587 has been marked as a duplicate of this bug. ***