Skip to content

Commit e4d9994

Browse files
rroesch1artembilan
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. **Auto-cherry-pick to `3.0.x`** # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java # spring-kafka/src/test/java/org/springframework/kafka/listener/TransactionalContainerTests.java
1 parent 47ba5da commit e4d9994

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 {
@@ -2289,13 +2290,13 @@ private RuntimeException doInvokeBatchListener(final ConsumerRecords<K, V> recor
22892290
}
22902291
}
22912292
catch (RuntimeException e) {
2293+
this.batchFailed = true;
22922294
failureTimer(sample, null);
22932295
batchInterceptAfter(records, e);
22942296
if (this.commonErrorHandler == null) {
22952297
throw e;
22962298
}
22972299
try {
2298-
this.batchFailed = true;
22992300
invokeBatchErrorHandler(records, recordList, e);
23002301
commitOffsetsIfNeededAfterHandlingError(records);
23012302
}

0 commit comments

Comments
 (0)