Skip to content

Commit 3cdb5a6

Browse files
committed
Polish "Align Kafka's missingTopicsFatal default value"
See gh-20917
1 parent a12eace commit 3cdb5a6

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,7 +53,6 @@
5353
* @author Stephane Nicoll
5454
* @author Artem Bilan
5555
* @author Nakul Mishra
56-
* @author Dhiren Mathur
5756
* @since 1.5.0
5857
*/
5958
@ConfigurationProperties(prefix = "spring.kafka")

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.junit.jupiter.api.Test;
3939

4040
import org.springframework.boot.autoconfigure.AutoConfigurations;
41-
import org.springframework.boot.autoconfigure.kafka.KafkaProperties.Listener;
4241
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
4342
import org.springframework.context.annotation.Bean;
4443
import org.springframework.context.annotation.Configuration;
@@ -86,7 +85,6 @@
8685
* @author Stephane Nicoll
8786
* @author Eddú Meléndez
8887
* @author Nakul Mishra
89-
* @author Dhiren Mathur
9088
*/
9189
class KafkaAutoConfigurationTests {
9290

@@ -404,17 +402,6 @@ void listenerProperties() {
404402
});
405403
}
406404

407-
@Test
408-
void listenerPropertiesMatchDefaults() {
409-
this.contextRunner.run((context) -> {
410-
Listener listenerProperties = new KafkaProperties().getListener();
411-
AbstractKafkaListenerContainerFactory<?, ?, ?> kafkaListenerContainerFactory = (AbstractKafkaListenerContainerFactory<?, ?, ?>) context
412-
.getBean(KafkaListenerContainerFactory.class);
413-
ContainerProperties containerProperties = kafkaListenerContainerFactory.getContainerProperties();
414-
assertThat(containerProperties.isMissingTopicsFatal()).isEqualTo(listenerProperties.isMissingTopicsFatal());
415-
});
416-
}
417-
418405
@Test
419406
void testKafkaTemplateRecordMessageConverters() {
420407
this.contextRunner.withUserConfiguration(MessageConverterConfiguration.class)
@@ -581,17 +568,6 @@ void testConcurrentKafkaListenerContainerFactoryWithCustomConsumerFactory() {
581568
});
582569
}
583570

584-
@Test
585-
void testConcurrentKafkaListenerContainerFactoryMatchesDefaults() {
586-
Listener listenerProperties = new KafkaProperties().getListener();
587-
this.contextRunner.withUserConfiguration(ConsumerFactoryConfiguration.class).run((context) -> {
588-
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context
589-
.getBean(ConcurrentKafkaListenerContainerFactory.class);
590-
assertThat(kafkaListenerContainerFactory.getContainerProperties().isMissingTopicsFatal())
591-
.isEqualTo(listenerProperties.isMissingTopicsFatal());
592-
});
593-
}
594-
595571
@Configuration(proxyBeanMethods = false)
596572
static class MessageConverterConfiguration {
597573

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2012-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.kafka;
18+
19+
import org.apache.kafka.clients.producer.KafkaProducer;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.boot.autoconfigure.kafka.KafkaProperties.Listener;
23+
import org.springframework.kafka.listener.ContainerProperties;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Tests for {@link KafkaProducer}.
29+
*
30+
* @author Stephane Nicoll
31+
*/
32+
class KafkaPropertiesTests {
33+
34+
@Test
35+
void listenerDefaultValuesAreConsistent() {
36+
ContainerProperties container = new ContainerProperties("test");
37+
Listener listenerProperties = new KafkaProperties().getListener();
38+
assertThat(listenerProperties.isMissingTopicsFatal()).isEqualTo(container.isMissingTopicsFatal());
39+
}
40+
41+
}

0 commit comments

Comments
 (0)