Skip to content

Commit 7077605

Browse files
authored
Tuning common code used for watches and key lookup (#1281)
1 parent f60390e commit 7077605

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/main/java/io/nats/client/impl/NatsFeatureBase.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,15 @@ protected void visitSubject(List<String> subjects, DeliverPolicy deliverPolicy,
9191
Duration timeout = js.getTimeout();
9292
JetStreamSubscription sub = js.subscribe(null, pso);
9393
try {
94-
boolean lastWasNull = false;
9594
long pending = sub.getConsumerInfo().getCalculatedPending();
9695
while (pending > 0) { // no need to loop if nothing pending
9796
Message m = sub.nextMessage(timeout);
9897
if (m == null) {
99-
if (lastWasNull) {
100-
return; // two timeouts in a row is enough
101-
}
102-
lastWasNull = true;
98+
return; // if there are no messages by the timeout, we are done.
10399
}
104-
else {
105-
handler.onMessage(m);
106-
if (--pending == 0) {
107-
return;
108-
}
109-
lastWasNull = false;
100+
handler.onMessage(m);
101+
if (--pending == 0) {
102+
return;
110103
}
111104
}
112105
}

0 commit comments

Comments
 (0)