Return-Path: Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: (qmail 78675 invoked from network); 15 Jan 2008 15:04:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2008 15:04:23 -0000 Received: (qmail 80607 invoked by uid 500); 15 Jan 2008 15:04:12 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 80489 invoked by uid 500); 15 Jan 2008 15:04:12 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 80477 invoked by uid 99); 15 Jan 2008 15:04:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2008 07:04:11 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2008 15:04:06 +0000 Received: by brutus.apache.org (Postfix, from userid 33) id C864A714204; Tue, 15 Jan 2008 07:03:58 -0800 (PST) From: bugzilla@apache.org To: log4j-dev@logging.apache.org Subject: DO NOT REPLY [Bug 44032] - NullPointerException in RollingFileAppender In-Reply-To: X-Bugzilla-Reason: AssignedTo Message-Id: <20080115150358.C864A714204@brutus.apache.org> Date: Tue, 15 Jan 2008 07:03:58 -0800 (PST) X-Virus-Checked: Checked by ClamAV on apache.org DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=44032 ------- Additional Comments From peter@baxter-it.com 2008-01-15 07:03 ------- We had a similar problem. The problem is that we use an AsynchAppender and a SocketAppender for logging. Because of how AsynchAppender works, it is possible that ThrowableInformation.getThrowableStrRep() runs on one LoggingEvent at the same time. public String[] getThrowableStrRep() { if(rep != null) { return (String[]) rep.clone(); } else { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); throwable.printStackTrace(pw); pw.flush(); LineNumberReader reader = new LineNumberReader( new StringReader(sw.toString())); ArrayList lines = new ArrayList(); try { String line = reader.readLine(); while(line != null) { lines.add(line); line = reader.readLine(); } } catch(IOException ex) { lines.add(ex.toString()); } rep = new String[lines.size()]; lines.toArray(rep); } return rep; } The problem is with ThrowableInformation.rep. If the first concurrent thread gets only to rep = new String[lines.size()]; and then the next concurrent thread gets to if(rep != null), then only rep.clone(); is returned with an empty array. Then later concurrent thread #1 will fill up the array but that's already late for the another concurrent thread. I think in this case the solution would be either to a) synchronize on ThrowableInformation.getThrowableStrRep() or b) modify rep = new String[lines.size()]; lines.toArray(rep); in method with String[] tempRep = new String[lines.size()]; lines.toArray(tempRep); rep = tempRep; -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org