michaeljmarshall commented on code in PR #20242:
URL: https://github.com/apache/pulsar/pull/20242#discussion_r1188120436


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -2153,9 +2153,14 @@ private CompletableFuture<Void> seekAsyncInternal(long 
requestId, ByteBuf seek,
 
         MessageIdAdv originSeekMessageId = seekMessageId;
         seekMessageId = (MessageIdAdv) seekId;
-        duringSeek.set(true);
+        
+        if (!duringSeek.compareAndSet(false, true)) {
+            log.warn("[{}][{}] Attempting to seek operation that is already in 
progress, cancelling {}", 
+                    topic, subscription, seekBy);
+            seekFuture.cancel(true);

Review Comment:
   Nit: I think an `IllegalStateException` would be a clearer exception 
indicating to the user that it was not a valid time to call this method. One 
problem with `CancellationException` is that it has no message. However, I see 
that there is a warning log indicating the problem, so it might be fine.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to