You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2007/12/06 14:47:05 UTC
DO NOT REPLY [Bug 44032] New: - NullPointerException in RollingFileAppender
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44032>.
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
Summary: NullPointerException in RollingFileAppender
Product: Log4j
Version: 1.2
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P2
Component: Appender
AssignedTo: log4j-dev@logging.apache.org
ReportedBy: ulrich.voigt@gmx.de
I've got the following NullPointerException:
java.lang.NullPointerException
at java.io.Writer.write(Writer.java:126)
at org.apache.log4j.helpers.CountingQuietWriter.write(CountingQuietWriter.java:45)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:309)
at org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:263)
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.warn(Category.java:1060)
at ..... my classes .....
I guess that the message I wanted to log was != null and was logged correctly.
--
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
DO NOT REPLY [Bug 44032] - NullPointerException in RollingFileAppender
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44032>.
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 ulrich.voigt@gmx.de 2008-01-16 09:44 -------
The solution looks good to me. I prefer solution b) because I cannot estimate
the overall impacts of solution a).
My problem is that the bug occurs very rarely. I got only two cases in 2 months.
So I could not say for sure that the patch fixes the problem :-(
Anyhow: Can someone please commit the patch?
--
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
DO NOT REPLY [Bug 44032] - NullPointerException in RollingFileAppender
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44032>.
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 ulrich.voigt@gmx.de 2007-12-06 06:04 -------
I forgot to mention that the problem occured with version 1.2.15.
--
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
DO NOT REPLY [Bug 44032] - NullPointerException in RollingFileAppender
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44032>.
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
ulrich.voigt@gmx.de changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |PatchAvailable
--
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
DO NOT REPLY [Bug 44032] - NullPointerException in RollingFileAppender
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44032>.
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
DO NOT REPLY [Bug 44032] - ThrowableInformation.getThrowableStringRep() can return null lines.
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44032>.
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
carnold@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Summary|NullPointerException in |ThrowableInformation.getThro
|RollingFileAppender |wableStringRep() can return
| |null lines.
------- Additional Comments From carnold@apache.org 2008-01-17 08:57 -------
Changed summary of bug since bug is not specific to RollingFileAppender.
Changes committed in rev 612863.
In addition to the synchronization issue, there was an isolation issue. On every call except the first, the
cached string representation was cloned before being returned. However, if you got the first call, you
could "rewrite" the string representation by modifying the returned value.
ThrowableInformationTest.testIsolation would fail with log4j 1.2.15. Whatever it did, it should have been
consistent. Either everyone should be able to rewrite or no one should be able to rewrite.
--
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