RivenSun2 commented on PR #13270: URL: https://github.com/apache/kafka/pull/13270#issuecomment-1435480289
@showuon Thanks for your suggestions! To be honest, I also considered throwing an exception directly in the `timeToNextHeartbeat` method before, because this is also done in the `AbstractCoordinator#pollHeartbeat` method. Throwing an exception here allows most users to jump out of their loop code (including the recommended usage on the `KafkaConsumer` class annotation). However, if the user uses a method similar to the following, it will still fall into an infinite loop, **even if they have already perceived that the poll method has thrown an exception.** ``` while (true) { try { consumer.poll(duration); } catch (Exception e) { log.error("has error when consumer poll!", e); } } ``` The current modification of this PR is compatible with this case. If we don't consider this case, I think throwing an exception here is one of the easiest ways in the short term. Thanks. -- 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