OPENJPA-2321: Synchronizing logging output stream causes deadlock when used some JDK LogManger derivative - back ported to 2.1.x Pinaki's trunk changes.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1434944 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Heath Thomann 2013-01-17 22:40:34 +00:00
parent e3b1f02221
commit 7d31775a03
1 changed files with 4 additions and 8 deletions

View File

@ -302,24 +302,21 @@ public class LogFactoryImpl
protected void log(short level, String message, Throwable t) {
String msg = formatMessage(level, message, t);
synchronized (_out) {
_out.print(msg);
}
_out.println(msg);
}
/**
* Convert <code>message</code> into a string ready to be written to
* the log. The string should include the terminating newline.
* the log.
*
* @param t may be null
*/
protected String formatMessage(short level, String message,
Throwable t) {
protected String formatMessage(short level, String message, Throwable t) {
// we write to a StringBuilder and then flush it all at
// once as a single line, since some environments(e.g., JBoss)
// override the System output stream to flush any calls
// to write without regard to line breaks, making the
// output incomprehensibe.
// output incomprehensible.
StringBuilder buf = new StringBuilder();
buf.append(getOffset());
@ -335,7 +332,6 @@ public class LogFactoryImpl
buf.append(_channel);
buf.append(" - ");
buf.append(message);
buf.append(NEWLINE);
if (t != null) {
StringWriter swriter = new StringWriter();