Skip to content

Commit 4565858

Browse files
Synchronize Access
The `wip` variable needs its access to be synchronized. Then it calls drainAndComplete outside the lock.
1 parent 2e8c1b5 commit 4565858

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/rx/internal/operators/OperatorMerge.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,13 @@ public void request(long n) {
494494
} else {
495495
REQUESTED.getAndAdd(this, n);
496496
if (ms.drainQueuesIfNeeded()) {
497-
if (ms.wip == 0 && ms.scalarValueQueue != null && ms.scalarValueQueue.isEmpty()) {
497+
boolean sendComplete = false;
498+
synchronized (this) {
499+
if (ms.wip == 0 && ms.scalarValueQueue != null && ms.scalarValueQueue.isEmpty()) {
500+
sendComplete = true;
501+
}
502+
}
503+
if (sendComplete) {
498504
ms.drainAndComplete();
499505
}
500506
}

0 commit comments

Comments
 (0)