Skip to content

Commit

Permalink
GH-3076: Set batchFailed in ListenerConsumer even if no `commonEr…
Browse files Browse the repository at this point in the history
…rorHandler`

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)
  • Loading branch information
rroesch1 authored and spring-builds committed Mar 5, 2024
1 parent d8bcab0 commit cccbd44
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
* @author Francois Rosiere
* @author Daniel Gentes
* @author Soby Chacko
* @author Raphael Rösch
*/
public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
extends AbstractMessageListenerContainer<K, V> implements ConsumerPauseResumeEventPublisher {
Expand Down Expand Up @@ -2313,13 +2314,13 @@ private RuntimeException doInvokeBatchListener(final ConsumerRecords<K, V> recor
}
}
catch (RuntimeException e) {
this.batchFailed = true;
failureTimer(sample, null);
batchInterceptAfter(records, e);
if (this.commonErrorHandler == null) {
throw e;
}
try {
this.batchFailed = true;
invokeBatchErrorHandler(records, recordList, e);
commitOffsetsIfNeededAfterHandlingError(records);
}
Expand Down

0 comments on commit cccbd44

Please sign in to comment.