Skip to content

Commit c671246

Browse files
sobychackoartembilan
authored andcommitted
GH-2991: Fix unwanted warning logs in KMLC
Fixes: #2991 There is a warning log from `KafkaMessageListenerContainter#checkRebalanceCommits` that unconditionally prints that offsets could not be committed. Because of this unconditional check, the messages are very likely to be false positives. Fixing this by adding a check to see if there are indeed uncommitted records. (cherry picked from commit f9476a3)
1 parent e36c22c commit c671246

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 the original author or authors.
2+
* Copyright 2016-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -159,6 +159,7 @@
159159
* @author Tomaz Fernandes
160160
* @author Francois Rosiere
161161
* @author Daniel Gentes
162+
* @author Soby Chacko
162163
*/
163164
public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
164165
extends AbstractMessageListenerContainer<K, V> implements ConsumerPauseResumeEventPublisher {
@@ -1711,9 +1712,10 @@ private void checkRebalanceCommits() {
17111712
.stream()
17121713
.filter(entry -> !this.assignedPartitions.contains(entry.getKey()))
17131714
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
1714-
this.logger.warn(() -> "These offsets could not be committed; partition(s) lost during rebalance: "
1715-
+ uncommitted);
1716-
1715+
if (!uncommitted.isEmpty()) {
1716+
this.logger.warn(() -> "These offsets could not be committed; partition(s) lost during rebalance: "
1717+
+ uncommitted);
1718+
}
17171719
this.commitsDuringRebalance.clear();
17181720
this.logger.debug(() -> "Commit list: " + commits);
17191721
commitSync(commits);

0 commit comments

Comments
 (0)