From a4eda3417077b8c8e49b828cdf7dd18fa3c6efd4 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 10 Aug 2021 08:34:28 +0200 Subject: [PATCH] Start building against Spring Kafka 2.8.0-M2 snapshots See gh-27609 --- .../kafka/KafkaAutoConfigurationTests.java | 39 +++++-------------- .../spring-boot-dependencies/build.gradle | 2 +- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index e5b0095d83..4c6d842854 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -57,12 +57,12 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaAdmin; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.listener.AfterRollbackProcessor; +import org.springframework.kafka.listener.BatchErrorHandler; import org.springframework.kafka.listener.ConsumerAwareRebalanceListener; import org.springframework.kafka.listener.ContainerProperties; import org.springframework.kafka.listener.ContainerProperties.AckMode; +import org.springframework.kafka.listener.ErrorHandler; import org.springframework.kafka.listener.RecordInterceptor; -import org.springframework.kafka.listener.SeekToCurrentBatchErrorHandler; -import org.springframework.kafka.listener.SeekToCurrentErrorHandler; import org.springframework.kafka.listener.adapter.RecordFilterStrategy; import org.springframework.kafka.security.jaas.KafkaJaasLoginModuleInitializer; import org.springframework.kafka.support.converter.BatchMessageConverter; @@ -508,16 +508,17 @@ class KafkaAutoConfigurationTests { @Test void testConcurrentKafkaListenerContainerFactoryWithCustomErrorHandler() { - this.contextRunner.withUserConfiguration(ErrorHandlerConfiguration.class).run((context) -> { - ConcurrentKafkaListenerContainerFactory factory = context - .getBean(ConcurrentKafkaListenerContainerFactory.class); - assertThat(factory).hasFieldOrPropertyWithValue("errorHandler", context.getBean("errorHandler")); - }); + this.contextRunner.withBean("errorHandler", ErrorHandler.class, () -> mock(ErrorHandler.class)) + .run((context) -> { + ConcurrentKafkaListenerContainerFactory factory = context + .getBean(ConcurrentKafkaListenerContainerFactory.class); + assertThat(factory).hasFieldOrPropertyWithValue("errorHandler", context.getBean("errorHandler")); + }); } @Test void concurrentKafkaListenerContainerFactoryInBatchModeShouldUseBatchErrorHandler() { - this.contextRunner.withUserConfiguration(BatchErrorHandlerConfiguration.class) + this.contextRunner.withBean("batchErrorHandler", BatchErrorHandler.class, () -> mock(BatchErrorHandler.class)) .withPropertyValues("spring.kafka.listener.type=batch").run((context) -> { ConcurrentKafkaListenerContainerFactory factory = context .getBean(ConcurrentKafkaListenerContainerFactory.class); @@ -538,7 +539,7 @@ class KafkaAutoConfigurationTests { @Test void concurrentKafkaListenerContainerFactoryInBatchModeAndSimpleErrorHandlerShouldBeNull() { this.contextRunner.withPropertyValues("spring.kafka.listener.type=batch") - .withUserConfiguration(ErrorHandlerConfiguration.class).run((context) -> { + .withBean("errorHandler", ErrorHandler.class, () -> mock(ErrorHandler.class)).run((context) -> { ConcurrentKafkaListenerContainerFactory factory = context .getBean(ConcurrentKafkaListenerContainerFactory.class); assertThat(factory).hasFieldOrPropertyWithValue("errorHandler", null); @@ -663,26 +664,6 @@ class KafkaAutoConfigurationTests { } - @Configuration(proxyBeanMethods = false) - static class ErrorHandlerConfiguration { - - @Bean - SeekToCurrentErrorHandler errorHandler() { - return new SeekToCurrentErrorHandler(); - } - - } - - @Configuration(proxyBeanMethods = false) - static class BatchErrorHandlerConfiguration { - - @Bean - SeekToCurrentBatchErrorHandler batchErrorHandler() { - return new SeekToCurrentBatchErrorHandler(); - } - - } - @Configuration(proxyBeanMethods = false) static class AfterRollbackProcessorConfiguration { diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 6d2c25012b..d5052863c6 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1687,7 +1687,7 @@ bom { ] } } - library("Spring Kafka", "2.8.0-M1") { + library("Spring Kafka", "2.8.0-SNAPSHOT") { group("org.springframework.kafka") { modules = [ "spring-kafka",