Skip to content

Commit b8da4a9

Browse files
committed
synchronize access to subscription for null check in OperatorMulticast
1 parent eb6ae37 commit b8da4a9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

rxjava-core/src/main/java/rx/internal/operators/OperatorMulticast.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,13 @@ public void call() {
137137
}));
138138

139139
// now that everything is hooked up let's subscribe
140-
if (subscription!=null)
141-
source.unsafeSubscribe(subscription);
140+
// as long as the subscription is not null
141+
boolean subscriptionIsNull;
142+
synchronized(guard) {
143+
subscriptionIsNull = subscription == null;
144+
}
145+
if (!subscriptionIsNull)
146+
source.unsafeSubscribe(subscription);
142147
}
143148
}
144149
}

0 commit comments

Comments
 (0)