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
|