From dcc87bd246a94a1a56a73e09b61b11442b31470e Mon Sep 17 00:00:00 2001 From: Bruno Bieth Date: Fri, 1 Nov 2013 11:35:28 +0100 Subject: [PATCH] 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. --- util/log/src/main/scala/sbt/ConsoleOut.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/log/src/main/scala/sbt/ConsoleOut.scala b/util/log/src/main/scala/sbt/ConsoleOut.scala index 916c3727e..07f17ff72 100644 --- a/util/log/src/main/scala/sbt/ConsoleOut.scala +++ b/util/log/src/main/scala/sbt/ConsoleOut.scala @@ -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() } } -} \ No newline at end of file +}