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


##########
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:
   Please add a `checkArgumentAsync` utility method to FutureUtil so that code 
doesn't get duplicated in all cases where `Preconditions.checkArgument` was 
eliminated. In `checkArgumentAsync`, `Preconditions.checkArgument` can be used 
and the exception is simple caught.



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