Bug 36587 - Printing throwable stacktrace throwing null pointer exception
Summary: Printing throwable stacktrace throwing null pointer exception
Status: RESOLVED DUPLICATE of bug 35324
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords: JDK1.4
Depends on:
Blocks:
 
Reported: 2005-09-10 01:12 UTC by komethagan
Modified: 2007-03-14 21:41 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description komethagan 2005-09-10 01:12:26 UTC
Log4j - WriteAppender is throwing a nullpointerexception when the first 
throwableinformation's stacktrace element is null. Have Log4j write a "null" 
string instead of throwing an excpetion.
Comment 1 Kay Abendroth 2006-11-11 12:54:59 UTC
Can you provide a piece of code that shows this behaviour?
Comment 2 Elias Ross 2007-01-26 18:17:20 UTC
Here is a test case

  public void testThrowableCause() throws Exception {
    // hack for 1.4
    Field f = PlatformInfo.class.getDeclaredField("hasStackTraceElement");
    f.setAccessible(true);
    f.set(null, new Integer(0));
    assertEquals(false, PlatformInfo.hasStackTraceElement());
    Throwable t = new Throwable("Freedom") {
      public String getNextException() { 
        return "cheese";
      }
      public void printStackTrace(PrintWriter pw) {
        pw.println((Object)null);
        pw.print((Object)null);
      }
    };
    
    ThrowableInformation ti = new ThrowableInformation(t);
    String s[] = ti.getThrowableStrRep();
    for (int i = 0; i < s.length; i++)
      System.out.println(s[i]);
  }
  
The second "print" causes this.
Comment 3 Curt Arnold 2007-02-20 23:23:45 UTC

*** This bug has been marked as a duplicate of 35234 ***
Comment 4 Henri Yandell 2007-03-13 12:46:22 UTC
(Duplicate of 35324, not 35234)
Comment 5 Jacob Kjome 2007-03-14 21:41:48 UTC

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