Skip to content

Commit cfc2c5f

Browse files
committed
Made a few modifications to the thread safe MessageRecorder.
1 parent 8d9135e commit cfc2c5f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

scalatest/src/main/scala/org/scalatest/ConcurrentInformer.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,11 @@ private[scalatest] object ConcurrentDocumenter {
132132
//
133133
private[scalatest] class MessageRecorder(dispatch: Reporter) extends ThreadAwareness {
134134

135-
@volatile private var messages = List[(String, Option[Any], RecordedMessageEventFun, Option[Location])]()
135+
private var messages = List.empty[(String, Option[Any], RecordedMessageEventFun, Option[Location])]
136136

137137
// Returns them in order recorded
138-
private def recordedMessages: List[(String, Option[Any], RecordedMessageEventFun, Option[Location])] = synchronized {
139-
messages.reverse
140-
}
138+
private def recordedMessages: List[(String, Option[Any], RecordedMessageEventFun, Option[Location])] =
139+
synchronized { messages.reverse }
141140

142141
def apply(message: String, payload: Option[Any], eventFun: RecordedMessageEventFun, location: Option[Location]): Unit = {
143142
requireNonNull(message, payload)
@@ -147,10 +146,8 @@ private[scalatest] class MessageRecorder(dispatch: Reporter) extends ThreadAware
147146
}
148147

149148
def recordedEvents(testWasPending: Boolean, testWasCanceled: Boolean): collection.immutable.IndexedSeq[RecordableEvent] = {
150-
synchronized {
151-
Vector.empty ++ recordedMessages.map { case (message, payload, eventFun, location) =>
152-
eventFun(message, payload, true, testWasPending, testWasCanceled, location)
153-
}
149+
Vector.empty ++ recordedMessages.map { case (message, payload, eventFun, location) =>
150+
eventFun(message, payload, true, testWasPending, testWasCanceled, location)
154151
}
155152
}
156153
}

0 commit comments

Comments
 (0)