Skip to content

Commit b7a3835

Browse files
committed
Add synchronized block for mutable builders
1 parent 2320db2 commit b7a3835

File tree

1 file changed

+10
-6
lines changed
  • keywords-Fork/src/main/scala/com/thoughtworks/dsl/keywords

1 file changed

+10
-6
lines changed

keywords-Fork/src/main/scala/com/thoughtworks/dsl/keywords/Fork.scala

+10-6
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,19 @@ object Fork {
113113
val element = !ForEach(fork.elements)
114114
counter.incrementAndGet()
115115
try {
116-
builder ++= !Shift(mapper(element));
117-
()
116+
val result = !Shift(mapper(element))
117+
builder.synchronized[Unit] {
118+
builder ++= result
119+
}
118120
} catch {
119121
case MultipleException(throwableSet) =>
120-
exceptionBuilder ++= throwableSet;
121-
()
122+
exceptionBuilder.synchronized[Unit] {
123+
exceptionBuilder ++= throwableSet
124+
}
122125
case e: Throwable =>
123-
exceptionBuilder += e;
124-
()
126+
exceptionBuilder.synchronized[Unit] {
127+
exceptionBuilder += e
128+
}
125129
} finally {
126130
if (counter.decrementAndGet() > 0) {
127131
!Continue

0 commit comments

Comments
 (0)