avoid deadlock in ConsoleOut.systemOutOverwrite

System.out can be reset after being captured by `val lockObject`.
Then locking `lockObject` and calling `println()` could lead to a
deadlock.
This commit is contained in:
Bruno Bieth 2013-11-01 11:35:28 +01:00 committed by Mark Harrah
parent b337f3d9ac
commit dcc87bd246
1 changed files with 3 additions and 3 deletions

View File

@ -34,8 +34,8 @@ object ConsoleOut
def println(): Unit = synchronized {
val s = current.toString
if(ConsoleLogger.formatEnabled && last.exists(lmsg => f(s, lmsg)))
System.out.print(OverwriteLine)
System.out.println(s)
lockObject.print(OverwriteLine)
lockObject.println(s)
last = Some(s)
current = new java.lang.StringBuffer
}
@ -59,4 +59,4 @@ object ConsoleOut
def println(s: String) = { out.write(s); println() }
def println() = { out.newLine(); out.flush() }
}
}
}