Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected void doHandle(Exception thrownException, ConsumerRecords<?, ?> records
if (cause != null) {
Class<? extends Throwable> causeClass = cause.getClass();
for (Entry<Class<? extends Throwable>, ContainerAwareBatchErrorHandler> entry : this.delegates.entrySet()) {
if (entry.getKey().equals(causeClass)) {
if (entry.getKey().isAssignableFrom(causeClass)) {
entry.getValue().handle(thrownException, records, consumer, container, invokeListener);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void handle(Exception thrownException, @Nullable List<ConsumerRecord<?, ?
if (cause != null) {
Class<? extends Throwable> causeClass = cause.getClass();
for (Entry<Class<? extends Throwable>, ContainerAwareErrorHandler> entry : this.delegates.entrySet()) {
if (entry.getKey().equals(causeClass)) {
if (entry.getKey().isAssignableFrom(causeClass)) {
handled = true;
entry.getValue().handle(thrownException, records, consumer, container);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.junit.jupiter.api.Test;

import org.springframework.kafka.KafkaException;

/**
* @author Gary Russell
* @since 2.7.4
Expand All @@ -48,7 +50,7 @@ void testRecordDelegates() {
eh.handle(wrap(new IOException()), Collections.emptyList(), mock(Consumer.class),
mock(MessageListenerContainer.class));
verify(def).handle(any(), any(), any(), any());
eh.handle(wrap(new RuntimeException()), Collections.emptyList(), mock(Consumer.class),
eh.handle(wrap(new KafkaException("test")), Collections.emptyList(), mock(Consumer.class),
mock(MessageListenerContainer.class));
verify(three).handle(any(), any(), any(), any());
eh.handle(wrap(new IllegalArgumentException()), Collections.emptyList(), mock(Consumer.class),
Expand All @@ -72,7 +74,7 @@ void testBatchDelegates() {
eh.handle(wrap(new IOException()), mock(ConsumerRecords.class), mock(Consumer.class),
mock(MessageListenerContainer.class), mock(Runnable.class));
verify(def).handle(any(), any(), any(), any(), any());
eh.handle(wrap(new RuntimeException()), mock(ConsumerRecords.class), mock(Consumer.class),
eh.handle(wrap(new KafkaException("test")), mock(ConsumerRecords.class), mock(Consumer.class),
mock(MessageListenerContainer.class), mock(Runnable.class));
verify(three).handle(any(), any(), any(), any(), any());
eh.handle(wrap(new IllegalArgumentException()), mock(ConsumerRecords.class), mock(Consumer.class),
Expand Down