sijie commented on a change in pull request #3622: add reset cousor to a 
specific message time
URL: https://github.com/apache/pulsar/pull/3622#discussion_r258552606
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
 ##########
 @@ -1050,14 +1050,13 @@ protected void handleSeek(CommandSeek seek) {
         final long requestId = seek.getRequestId();
         CompletableFuture<Consumer> consumerFuture = 
consumers.get(seek.getConsumerId());
 
-        // Currently only seeking on a message id is supported
-        if (!seek.hasMessageId()) {
+        if (!seek.hasMessageId() && !seek.hasMessageTime()) {
             ctx.writeAndFlush(
                     Commands.newError(requestId, ServerError.MetadataError, 
"Message id was not present"));
             return;
         }
 
-        if (consumerFuture != null && consumerFuture.isDone() && 
!consumerFuture.isCompletedExceptionally()) {
+        if (consumerFuture != null && consumerFuture.isDone() && 
!consumerFuture.isCompletedExceptionally() && seek.hasMessageId()) {
 
 Review comment:
   `consumerFuture != null && consumerFuture.isDone() && 
!consumerFuture.isCompletedExceptionally()` is a common expression. I would 
suggest moving it out of if branch and assign it to a temp boolean variable. so 
it can be reused later.
   
   ```suggestion
           boolean consumerCreated = consumerFuture != null && 
consumerFuture.isDone() && !consumerFuture.isCompletedExceptionally();
           if (consumerCreated && seek.hasMessageId()) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to