From 2c32f7699520f5678040288f4e6f3abb9d61446c Mon Sep 17 00:00:00 2001 From: chickenchickenlove Date: Sun, 17 Nov 2024 22:05:45 +0900 Subject: [PATCH] Fixes lint error. --- .../kafka/listener/KafkaMessageListenerContainer.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java b/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java index e9d187637..2d38945c2 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java @@ -1469,13 +1469,10 @@ protected void handleAsyncFailure() { // If we use failedRecords.clear() to remove copied record from failed records, // We may encounter race condition during this operation. - // Main Thread : copy 100 records from failed records. - // Thread A : Oops! I have an exception. Add record to failedRecords. (failedRecords size is 101) - // Main Thread : clear failedRecords! - // In this case, Main Thread misses one failed record. - int shouldRemoveCount = copyFailedRecords.size(); - for (int i = 0; i < shouldRemoveCount; i++) { - failedRecords.pollFirst(); + // Other, the thread which execute this block, may miss one failed record. + int capturedRecordsCount = copyFailedRecords.size(); + for (int i = 0; i < capturedRecordsCount; i++) { + this.failedRecords.pollFirst(); } // If any copied and failed record fails to complete due to an unexpected error,