lianetm commented on code in PR #19546:
URL: https://github.com/apache/kafka/pull/19546#discussion_r2058455119


##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -1797,31 +1801,48 @@ public void close() {
      * @throws InterruptException If the thread is interrupted before or while 
this function is called
      * @throws org.apache.kafka.common.KafkaException for any other error 
during close
      */
+    @Deprecated
     @Override
-    @SuppressWarnings("deprecation")
     public void close(Duration timeout) {
         delegate.close(timeout);
     }
 
     /**
-     * Wakeup the consumer. This method is thread-safe and is useful in 
particular to abort a long poll.
-     * The thread which is blocking in an operation will throw {@link 
org.apache.kafka.common.errors.WakeupException}.
-     * If no thread is blocking in a method which can throw {@link 
org.apache.kafka.common.errors.WakeupException}, the next call to such a method 
will raise it instead.
+     * Close the consumer cleanly. {@link CloseOptions} allows to specify a 
timeout and a
+     * {@link CloseOptions.GroupMembershipOperation membership operation}.
+     * If no timeout is specified, the default timeout of 30 seconds is uses.
+     * If no membership operation is specified, the {@link 
CloseOptions.GroupMembershipOperation#DEFAULT default

Review Comment:
   as above, would ~"leave group behaviour" be clearer than the generic 
"membership operation"?



##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -1776,10 +1777,13 @@ public void close() {
     }
 
     /**
-     * Tries to close the consumer cleanly within the specified timeout. This 
method waits up to
-     * {@code timeout} for the consumer to complete pending commits and leave 
the group.
+     * This method has been deprecated since Kafka 4.0 and should use {@link 
KafkaConsumer#close(CloseOptions)} instead.
+     * <p>
+     * Close the consumer with {@link 
CloseOptions.GroupMembershipOperation#DEFAULT default membership operation}

Review Comment:
   "membership operation" seems to generic to me really, this is only about 
"leave group behaviour" or similar. Would that be clearer as java doc?



##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -1797,31 +1801,48 @@ public void close() {
      * @throws InterruptException If the thread is interrupted before or while 
this function is called
      * @throws org.apache.kafka.common.KafkaException for any other error 
during close
      */
+    @Deprecated

Review Comment:
   since 4.1 really (helpful adding the since btw)



##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -1797,31 +1801,48 @@ public void close() {
      * @throws InterruptException If the thread is interrupted before or while 
this function is called
      * @throws org.apache.kafka.common.KafkaException for any other error 
during close
      */
+    @Deprecated
     @Override
-    @SuppressWarnings("deprecation")
     public void close(Duration timeout) {
         delegate.close(timeout);
     }
 
     /**
-     * Wakeup the consumer. This method is thread-safe and is useful in 
particular to abort a long poll.
-     * The thread which is blocking in an operation will throw {@link 
org.apache.kafka.common.errors.WakeupException}.
-     * If no thread is blocking in a method which can throw {@link 
org.apache.kafka.common.errors.WakeupException}, the next call to such a method 
will raise it instead.
+     * Close the consumer cleanly. {@link CloseOptions} allows to specify a 
timeout and a
+     * {@link CloseOptions.GroupMembershipOperation membership operation}.
+     * If no timeout is specified, the default timeout of 30 seconds is uses.
+     * If no membership operation is specified, the {@link 
CloseOptions.GroupMembershipOperation#DEFAULT default
+     * membership operation} is used.
+     * <p>
+     * This method waits up to the timeout for the consumer to complete 
pending commits and may leave the group,

Review Comment:
   ```suggestion
        * This method waits up to the timeout for the consumer to complete 
pending commits and maybe leave the group,
   ```



##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -1776,10 +1777,13 @@ public void close() {
     }
 
     /**
-     * Tries to close the consumer cleanly within the specified timeout. This 
method waits up to
-     * {@code timeout} for the consumer to complete pending commits and leave 
the group.
+     * This method has been deprecated since Kafka 4.0 and should use {@link 
KafkaConsumer#close(CloseOptions)} instead.
+     * <p>
+     * Close the consumer with {@link 
CloseOptions.GroupMembershipOperation#DEFAULT default membership operation}
+     * cleanly within the specified timeout. This method waits up to
+     * {@code timeout} for the consumer to complete pending commits and may 
leave the group (if applicable).

Review Comment:
   about the "and may leave the group (if applicable).", could we be explicit 
in this case, just to make things clear? (it will leave the group if it's a 
dynamic member). That's the only case here that the close has the DEFAULT 
membership behaviour I expect.



##########
clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java:
##########
@@ -1797,31 +1801,48 @@ public void close() {
      * @throws InterruptException If the thread is interrupted before or while 
this function is called
      * @throws org.apache.kafka.common.KafkaException for any other error 
during close
      */
+    @Deprecated
     @Override
-    @SuppressWarnings("deprecation")
     public void close(Duration timeout) {
         delegate.close(timeout);
     }
 
     /**
-     * Wakeup the consumer. This method is thread-safe and is useful in 
particular to abort a long poll.
-     * The thread which is blocking in an operation will throw {@link 
org.apache.kafka.common.errors.WakeupException}.
-     * If no thread is blocking in a method which can throw {@link 
org.apache.kafka.common.errors.WakeupException}, the next call to such a method 
will raise it instead.
+     * Close the consumer cleanly. {@link CloseOptions} allows to specify a 
timeout and a
+     * {@link CloseOptions.GroupMembershipOperation membership operation}.
+     * If no timeout is specified, the default timeout of 30 seconds is uses.
+     * If no membership operation is specified, the {@link 
CloseOptions.GroupMembershipOperation#DEFAULT default
+     * membership operation} is used.
+     * <p>
+     * This method waits up to the timeout for the consumer to complete 
pending commits and may leave the group,
+     * depending on the specified membership operation.
+     * If auto-commit is enabled, this will commit the current offsets if 
possible within the
+     * timeout. If the consumer is unable to complete offset commits and 
gracefully leave the group (if applicable)

Review Comment:
   yeah, a bit confusing, but in this case "leave" is correct, referring to 
"unable to ...leave"



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