MINOR: improve JavaDocs for consumer CloseOptions#19546
Conversation
frankvicky
left a comment
There was a problem hiding this comment.
@mjsax: Thanks for the significant improvement to the documentation!
Overall LGTM.
I have just two nits for consideration.
| * 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. |
There was a problem hiding this comment.
| * If no timeout is specified, the default timeout of 30 seconds is uses. | |
| * If no timeout is specified, the default timeout of 30 seconds is used. |
| * 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) |
There was a problem hiding this comment.
| * timeout. If the consumer is unable to complete offset commits and gracefully leave the group (if applicable) | |
| * timeout. If the consumer is unable to complete offset commits and gracefully leaves the group (if applicable) |
There was a problem hiding this comment.
yeah, a bit confusing, but in this case "leave" is correct, referring to "unable to ...leave"
| * @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 |
There was a problem hiding this comment.
| @Deprecated | |
| @Deprecated(since = "4.0") |
There was a problem hiding this comment.
since 4.1 really (helpful adding the since btw)
There was a problem hiding this comment.
Well, 4.1 :) -- c&p error form the previous PR...
| * Note that the execution time of callbacks (such as {@link OffsetCommitCallback} and | ||
| * {@link ConsumerRebalanceListener}) does not consume time from the close timeout. | ||
| * | ||
| * @param option see {@link CloseOptions}; cannot be {@code null} |
There was a problem hiding this comment.
We don't check whether CloseOptions is null. If users use close((CloseOptions) null), they get NullPointerException. Do we want to return IllegalArgumentException when input is null here? Thanks.
There was a problem hiding this comment.
yeah lets add a check and throw an IAException
There was a problem hiding this comment.
I think it's ok if users get NPE -- we say "cannot be null" so NPE should be expected?
There was a problem hiding this comment.
yeah, I personally prefer IAE too, but we do have this same NPE behaviour on args in many other consumer APIs too (ex. commit, position, committed,...I think almost all)
There was a problem hiding this comment.
Ok, so the verdict is we keep NPE. Thanks.
(Btw: also aligns to what KS does.)
| * <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). |
There was a problem hiding this 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.
There was a problem hiding this comment.
agreed, "if applicable" is pretty vague and I'd be left wondering if I saw this as a user
| * {@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} |
There was a problem hiding this 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?
| * 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 |
There was a problem hiding this comment.
as above, would ~"leave group behaviour" be clearer than the generic "membership operation"?
There was a problem hiding this comment.
agreed, would also be good to specify what the default leave behavior actually is
| * 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, |
There was a problem hiding this comment.
| * This method waits up to the timeout for the consumer to complete pending commits and may leave the group, | |
| * This method waits up to the timeout for the consumer to complete pending commits and maybe leave the group, |
| * @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 |
There was a problem hiding this comment.
since 4.1 really (helpful adding the since btw)
| * 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) |
There was a problem hiding this comment.
yeah, a bit confusing, but in this case "leave" is correct, referring to "unable to ...leave"
| /** | ||
| * 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. |
There was a problem hiding this comment.
| * This method has been deprecated since Kafka 4.0 and should use {@link KafkaConsumer#close(CloseOptions)} instead. | |
| * This method has been deprecated since Kafka 4.1 and should use {@link KafkaConsumer#close(CloseOptions)} instead. |
| * {@code timeout} for the consumer to complete pending commits and may leave the group (if applicable). | ||
| * 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 | ||
| * timeout. If the consumer is unable to complete offset commits and gracefully leave the group (if applicable) |
There was a problem hiding this comment.
(if applicable) is ok to use here as long as we specified when it's applicable earlier in the javadocs
|
Updates this PR. Call for review. |
lianetm
left a comment
There was a problem hiding this comment.
Thanks for the updates! Minor comments left, and also, could we fix this log that references the deprecated close?
I would personally remove the explicit func name from the log and just mention "the close operation/call", but as you prefer.
| * <p> | ||
| * Close the consumer with {@link CloseOptions.GroupMembershipOperation#DEFAULT default leave group behavior} | ||
| * cleanly within the specified timeout. This method waits up to | ||
| * {@code timeout} for the consumer to complete pending commits and maybe leaves the group (if the group is dynamic). |
There was a problem hiding this comment.
| * {@code timeout} for the consumer to complete pending commits and maybe leaves the group (if the group is dynamic). | |
| * {@code timeout} for the consumer to complete pending commits and maybe leave the group (if the member is dynamic). |
| * If no leave group behavior is specified, the {@link CloseOptions.GroupMembershipOperation#DEFAULT default | ||
| * leave group behavior} is used. | ||
| * <p> | ||
| * This method waits up to the timeout for the consumer to complete pending commits and maybe leaves the group, |
There was a problem hiding this comment.
| * This method waits up to the timeout for the consumer to complete pending commits and maybe leaves the group, | |
| * This method waits up to the timeout for the consumer to complete pending commits and maybe leave the group, |
There was a problem hiding this comment.
Cannot follow.
This method wait[s] ... and maybe leave[s] the group. -- Why would we remove the s?
There was a problem hiding this comment.
she's right, no s. English is confusing
There was a problem hiding this comment.
i don't know the proper grammar terminology here but essentially it's because the "maybe leave the group" is part of the X in the sentence "this method waits up to the timeout for the consumer to X"
here the "maybe leave the group" comes after an "and" which can be amiguous but in this context I think it makes more sense for it to be part of the X, ie "this method waits up to the timeout for the consumer to (complete pending commits and maybe leave the group)"
so its should be conjugated the same way as the thing before the and, ie the "complete pending commits"
since it's "complete" and not "completes", it should also be "leave" and not "leaves"
There was a problem hiding this comment.
technically the original sentence is also grammatically correct, however it doesn't mean exactly the same thing.
With the s it's is effectively saying "This method (waits up to the timeout for the consumer to complete pending commits) and maybe leaves the group" which implies leaving the group isn't part of the timeout.
Without the s it's grouped as "this method waits up to the timeout for the consumer to (complete pending commits and maybe leave the group)" which implies leaving the group is part of the timeout
There was a problem hiding this comment.
To make matters even more confusing, I noticed we actually do not pass the timeout into the consumer or producer's #close methods...
So technically-technically the original sentence is also correct code-wise, but imo that's kind of a bug
There was a problem hiding this comment.
Thanks for explaining. "Surprisingly", I could follow and it make sense to me 😂 -- Mr.John (english major) @vvcephei could not have explained it any better.
| * This method waits up to the timeout for the consumer to complete pending commits and maybe leaves the group, | ||
| * depending on the specified leave group behavior. | ||
| * 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 leaves the group (if applicable) |
There was a problem hiding this comment.
| * timeout. If the consumer is unable to complete offset commits and gracefully leaves the group (if applicable) | |
| * timeout. If the consumer is unable to complete offset commits and gracefully leave the group (if applicable) |
Reviewers: TengYao Chi <frankvicky@apache.org>, PoAn Yang <payang@apache.org>, Lianet Magrans <lmagrans@confluent.io>, Anna Sophie Blee-Goldman <ableegoldman@apache.org>
Reviewers: TengYao Chi frankvicky@apache.org, PoAn Yang
payang@apache.org, Lianet Magrans lmagrans@confluent.io, Anna
Sophie Blee-Goldman ableegoldman@apache.org