DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23019>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23019 NullPointerException in RollingFileAppender when called by AsyncAppender Summary: NullPointerException in RollingFileAppender when called by AsyncAppender Product: Log4j Version: 1.2 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Appender AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Log4j Version: 1.2.2 The subAppend(...) method in org.apache.log4j.WriterAppender throws in very rare cases a NullPointerException when used with an AsyncAppender. This occured during a loadtest with heavy load, only after many hours of opperation and with number of parallel requests more than 100 (120 simulated users with LoadRunner). There seems to be a running condition, where the string array returned by loggingEvent.getThrowableStrRep() is not properly filled up when used immediately after above call. The string array was created (check for non-null successfull), but the elements of that array was (in rare conditions) null at one moment and non-null some ms later. Trace output and modified code see below. The appender attached to the AsyncAppender is an own implementation deriving from RollingFileAppender. To find out the location where the NullPointerException is thrown, the WriterAppender class has been complemented with additional trace statements: protected void subAppend(LoggingEvent event) { try { this.qw.write(this.layout.format(event)); } catch (NullPointerException e) { System.out.println("WriterAppender.subAppend: this.qw.write (this.layout.format(event))"); throw e; } int len = -1; int i = -1; String[] s = null; String line = null; try { if(layout.ignoresThrowable()) { s = event.getThrowableStrRep(); if (s != null) { len = s.length; for(i = 0; i < len; i++) { line = s[i]; this.qw.write(line); this.qw.write(Layout.LINE_SEP); } } } } catch (NullPointerException e) { System.out.println("WriterAppender.subAppend: len="+len+", i="+i); System.out.println(" line="+line); if ((s != null) && (i>=0)) System.out.println(" s[i]="+s[i]); ThrowableInformation ti = event.getThrowableInformation(); if (ti != null) System.out.println(" event.throwableInfo.wasCloned="+ti.wasCloned()); throw e; } try { if(this.immediateFlush) { this.qw.flush(); } } catch (NullPointerException e) { System.out.println("WriterAppender.subAppend: flush"); throw e; } } This resulted in following trace output: WriterAppender.subAppend: len=40, i=0 line=null s[i]=com.frontwerks.jdf.net.BrokerException: Cannot get a socket connection, cannot invoke the request event.throwableInfo.wasCloned=false ---> TRACE-ERROR: could not append event: [EMAIL PROTECTED] java.lang.NullPointerException at java.io.Writer.write(Unknown Source) at org.apache.log4j.helpers.CountingQuietWriter.write (CountingQuietWriter.java:36) at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:316) at org.apache.log4j.RollingFileAppender.subAppend (RollingFileAppender.java:225) at org.apache.log4j.WriterAppender.append(WriterAppender.java:151) at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:222) ..... at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders (AppenderAttachableImpl.java:58) at org.apache.log4j.Dispatcher.run(AsyncAppender.java:326) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]