Skip to content

Commit

Permalink
Allow messages to be null in recording logger
Browse files Browse the repository at this point in the history
So that we know what's going on with spurious failures like:

```
[error] Test bloop.tasks.TestLoggingSpec.concurrentTestRunsHaveDifferentStreams failed: java.lang.NullPointerException: null, took 4.542 sec
[error]     at scala.collection.immutable.StringLike.stripSuffix(StringLike.scala:165)
[error]     at scala.collection.immutable.StringLike.stripSuffix$(StringLike.scala:164)
[error]     at scala.collection.immutable.StringOps.stripSuffix(StringOps.scala:29)
[error]     at bloop.logging.RecordingLogger.$anonfun$getMessages$1(RecordingLogger.scala:12)
[error]     at scala.collection.immutable.List.map(List.scala:287)
[error]     at bloop.logging.RecordingLogger.getMessages(RecordingLogger.scala:10)
[error]     at bloop.tasks.TestLoggingSpec.concurrentTestRunsHaveDifferentStreams(TestLoggingSpec.scala:52)
[error] ...
```
  • Loading branch information
jvican committed Mar 28, 2018
1 parent a466dfe commit 1ac59f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/test/scala/bloop/logging/RecordingLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class RecordingLogger extends AbstractLogger {
def clear(): Unit = messages.clear()
def getMessages(): List[(String, String)] = messages.iterator.asScala.toList.map {
// Remove trailing '\r' so that we don't have to special case for Windows
case (category, msg) => (category, msg.stripSuffix("\r"))
case (category, msg0) =>
val msg = if (msg0 == null) "<null reference>" else msg0
(category, msg.stripSuffix("\r"))
}

override val name: String = "RecordingLogger"
Expand Down

0 comments on commit 1ac59f2

Please sign in to comment.