Skip to content

Commit cccbd44

Browse files
rroesch1spring-builds
authored andcommitted
GH-3076: Set batchFailed in ListenerConsumer even if no commonErrorHandler
Fixes: #3076 The `ListenerConsumer` sets `batchFailed` to `true` only if `commonErrorHandler` is provided * Move `this.batchFailed = true;` in the `doInvokeBatchListener()` before any error handling. # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java # spring-kafka/src/test/java/org/springframework/kafka/listener/TransactionalContainerTests.java (cherry picked from commit e4d9994)
1 parent d8bcab0 commit cccbd44

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
* @author Francois Rosiere
161161
* @author Daniel Gentes
162162
* @author Soby Chacko
163+
* @author Raphael Rösch
163164
*/
164165
public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
165166
extends AbstractMessageListenerContainer<K, V> implements ConsumerPauseResumeEventPublisher {
@@ -2313,13 +2314,13 @@ private RuntimeException doInvokeBatchListener(final ConsumerRecords<K, V> recor
23132314
}
23142315
}
23152316
catch (RuntimeException e) {
2317+
this.batchFailed = true;
23162318
failureTimer(sample, null);
23172319
batchInterceptAfter(records, e);
23182320
if (this.commonErrorHandler == null) {
23192321
throw e;
23202322
}
23212323
try {
2322-
this.batchFailed = true;
23232324
invokeBatchErrorHandler(records, recordList, e);
23242325
commitOffsetsIfNeededAfterHandlingError(records);
23252326
}

0 commit comments

Comments
 (0)