kirktrue commented on code in PR #15640:
URL: https://github.com/apache/kafka/pull/15640#discussion_r1583451774


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/CompletableBackgroundEvent.java:
##########
@@ -27,19 +30,34 @@
 public abstract class CompletableBackgroundEvent<T> extends BackgroundEvent 
implements CompletableEvent<T> {
 
     private final CompletableFuture<T> future;
+    private final long deadlineMs;
 
-    protected CompletableBackgroundEvent(final Type type) {
+    protected CompletableBackgroundEvent(final Type type, final Timer timer) {
         super(type);
         this.future = new CompletableFuture<>();
+        Objects.requireNonNull(timer);
+
+        long currentTimeMs = timer.currentTimeMs();
+        long remainingMs = timer.remainingMs();
+
+        if (currentTimeMs > Long.MAX_VALUE - remainingMs)
+            this.deadlineMs = Long.MAX_VALUE;
+        else
+            this.deadlineMs = currentTimeMs + remainingMs;

Review Comment:
   Per the above, I added `CompletableEvent.calculateDeadlineMs()` to keep the 
code in a shared location.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to