zhanghaou commented on code in PR #25287:
URL: https://github.com/apache/pulsar/pull/25287#discussion_r2896250739


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java:
##########
@@ -662,7 +661,10 @@ public CompletableFuture<Void> acknowledgeAsync(MessageId 
messageId,
         }
         TransactionImpl txnImpl = null;
         if (null != txn) {
-            checkArgument(txn instanceof TransactionImpl);
+            if (!(txn instanceof TransactionImpl)) {
+                return FutureUtil.failedFuture(new IllegalArgumentException(
+                        "Expected txn to be an instance of TransactionImpl, 
but got " + txn.getClass().getName()));
+            }

Review Comment:
   @lhotari  Thanks for the review, do you mean switching to asynchronous 
validation like in the code below? If so, that would require quite a lot of 
code changes since all asynchronous tasks would need to be chained after the 
validation logic.
   ```
   public static CompletableFuture<Void> checkArgumentAsync(boolean expression,
                                                                String 
errorMessageTemplate,
                                                                @Nullable 
Object @Nullable ... errorMessageArgs) {
           try {
               Preconditions.checkArgument(expression, errorMessageTemplate, 
errorMessageArgs);
               return CompletableFuture.completedFuture(null);
           } catch (IllegalArgumentException e) {
               return failedFuture(e);
           }
       }
   ```



-- 
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]

Reply via email to