@@ -132,25 +132,17 @@ private[scalatest] object ConcurrentDocumenter {
132
132
//
133
133
private [scalatest] class MessageRecorder (dispatch : Reporter ) extends ThreadAwareness {
134
134
135
- private var messages = List [(String , Option [Any ], RecordedMessageEventFun , Option [Location ])]()
136
-
137
- // Should only be called by the thread that constructed this
138
- // ConcurrentInformer, because don't want to worry about synchronization here. Just send stuff from
139
- // other threads whenever they come in. So only call record after first checking isConstructingThread
140
- private def record (message : String , payload : Option [Any ], eventFun : RecordedMessageEventFun , location : Option [Location ]): Unit = {
141
- require(isConstructingThread)
142
- messages ::= (message, payload, eventFun, location)
143
- }
135
+ private var messages = List .empty[(String , Option [Any ], RecordedMessageEventFun , Option [Location ])]
144
136
145
137
// Returns them in order recorded
146
- private def recordedMessages : List [(String , Option [Any ], RecordedMessageEventFun , Option [Location ])] = messages.reverse
138
+ private def recordedMessages : List [(String , Option [Any ], RecordedMessageEventFun , Option [Location ])] =
139
+ synchronized { messages.reverse }
147
140
148
141
def apply (message : String , payload : Option [Any ], eventFun : RecordedMessageEventFun , location : Option [Location ]): Unit = {
149
142
requireNonNull(message, payload)
150
- if (isConstructingThread)
151
- record(message, payload, eventFun, location)
152
- else
153
- dispatch(eventFun(message, payload, false , false , false , location)) // Fire the info provided event using the passed function
143
+ synchronized {
144
+ messages ::= (message, payload, eventFun, location)
145
+ }
154
146
}
155
147
156
148
def recordedEvents (testWasPending : Boolean , testWasCanceled : Boolean ): collection.immutable.IndexedSeq [RecordableEvent ] = {
0 commit comments