m1a2st commented on code in PR #17409:
URL: https://github.com/apache/kafka/pull/17409#discussion_r1807554128
##########
clients/src/main/java/org/apache/kafka/common/internals/KafkaFutureImpl.java:
##########
@@ -192,6 +192,14 @@ public T get(long timeout, TimeUnit unit) throws
InterruptedException, Execution
public T getNow(T valueIfAbsent) throws ExecutionException {
try {
return completableFuture.getNow(valueIfAbsent);
+ } catch (CancellationException e) {
+ // In Java 23, When a CompletableFuture is cancelled, getNow()
will throw a CompletionException wrapping a
+ // CancellationException. whereas in Java < 23, it throws a
CompletionException directly.
+ if (e.getCause() instanceof CancellationException) {
+ throw (CancellationException) e.getCause();
+ } else {
+ throw new CancellationException(e.getMessage());
Review Comment:
The method exception signature doesn't have `Throwable`, so we can't throw
`e.getCause()`.
but we can throw `CancellationException e` directory.
--
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]