Repository navigation
Conversation
…rMetrics.close() close() closed the metadata consumers in its finally block before unlocking consumerFactoryLock. A Consumer.close() that threw skipped the unlock, so the lock stayed held by the closing thread, the remaining consumers were left open and the map was not cleared. KafkaConsumer.close() is documented to throw InterruptException and KafkaException, and close() reaches that block with the interrupt flag set when awaitTermination() is interrupted. * Close each metadata consumer on its own and log a failure instead of propagating it, so all of them are closed and the map is cleared * Release consumerFactoryLock in a nested finally Follow-up to spring-cloud#3332 Signed-off-by: Caio Vinicius <caioviniciuscv18@gmail.com>
olegz
pushed a commit
that referenced
this pull request
Nov 29, 2026
…se() close() closed the metadata consumers in its finally block before unlocking consumerFactoryLock. A Consumer.close() that threw skipped the unlock, so the lock stayed held by the closing thread, the remaining consumers were left open and the map was not cleared. KafkaConsumer.close() is documented to throw InterruptException and KafkaException, and close() reaches that block with the interrupt flag set when awaitTermination() is interrupted. * Close each metadata consumer on its own and log a failure instead of propagating it, so all of them are closed and the map is cleared * Release consumerFactoryLock in a nested finally Follow-up to #3332 Signed-off-by: Caio Vinicius <caioviniciuscv18@gmail.com> Resolves #3353 Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #3332, noticed while working on that fix.
close()closes the metadata consumers in itsfinallyblock beforeconsumerFactoryLock.unlock(). If aConsumer.close()throws, the unlock is skipped: the lock stays held by the closing thread, the remaining consumers are left open andmetadataConsumersis not cleared.KafkaConsumer.close()is documented to throwInterruptExceptionandKafkaException, andclose()reaches that block with the interrupt flag set whenawaitTermination()is interrupted.consumerFactoryLockin a nestedfinally.The new test creates two metadata consumers, one of which throws from
close(), and then checks from another thread thatconsumerFactoryLockcan be acquired:main: fails withconsumerFactoryLock is still held after close()KafkaBinderMetricsTestThe same block is on 5.0.x.