Skip to content

Commit 5ef80d6

Browse files
wyzhangWangyuan Zhang
authored andcommitted
Using isEmpty() instead of peek() to check if task queue is empty, since peek() implementation operates in a similar way to poll like a consumer which can lead to a multi-consumer scenario on a multi-producer-single-consumer queue, therefore getting into an infinite loop issue inside MPSC queue implementation.
1 parent a23029c commit 5ef80d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/io/cdap/http/internal/NonStickyEventExecutorGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void run() {
283283
//
284284
// The above cases can be distinguished by performing a
285285
// compareAndSet(NONE, RUNNING). If it returns "false", it is case 1; otherwise it is case 2.
286-
if (tasks.peek() == null || !state.compareAndSet(NONE, RUNNING)) {
286+
if (tasks.isEmpty() || !state.compareAndSet(NONE, RUNNING)) {
287287
return; // done
288288
}
289289
}

0 commit comments

Comments
 (0)