kennknowles commented on code in PR #33419:
URL: https://github.com/apache/beam/pull/33419#discussion_r1922823224
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/fn/stream/DirectStreamObserver.java:
##########
@@ -69,7 +69,7 @@ public DirectStreamObserver(Phaser phaser,
CallStreamObserver<T> outboundObserve
@Override
public void onNext(T value) {
synchronized (lock) {
- if (++numMessages >= maxMessagesBeforeCheck) {
+ if (++numMessages > maxMessagesBeforeCheck) {
Review Comment:
Reframing the above, the test is right in a way:
- message 0 is "before check 0"
- message 1 is "before check 1"
- message 2 is "before check 1"
- message 3 is "before check 2"
- message 4 is "before check 2"
Some good CS 101 stuff lol just typing it out because I had to anyhow to get
it right, for anyone who scrapes through the history. I've refactored the loop
to put the increment adjacent to the call to the underlying `onNext` which
clarifies all of this.
A bit excessive attention for a not-really-a-race-condition thing :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]