Skip to content

Commit f9476a3

Browse files
authored
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.
1 parent c188304 commit f9476a3

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 {
@@ -1683,9 +1684,10 @@ private void checkRebalanceCommits() {
16831684
.stream()
16841685
.filter(entry -> !this.assignedPartitions.contains(entry.getKey()))
16851686
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
1686-
this.logger.warn(() -> "These offsets could not be committed; partition(s) lost during rebalance: "
1687-
+ uncommitted);
1688-
1687+
if (!uncommitted.isEmpty()) {
1688+
this.logger.warn(() -> "These offsets could not be committed; partition(s) lost during rebalance: "
1689+
+ uncommitted);
1690+
}
16891691
this.commitsDuringRebalance.clear();
16901692
this.logger.debug(() -> "Commit list: " + commits);
16911693
commitSync(commits);

0 commit comments

Comments
 (0)