Skip to content

Commit

Permalink
Align Kafka's missingTopicsFatal default value
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimathu authored and snicoll committed Apr 11, 2020
1 parent 856543c commit a12eace
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Expand Up @@ -53,6 +53,7 @@
* @author Stephane Nicoll
* @author Artem Bilan
* @author Nakul Mishra
* @author Dhiren Mathur
* @since 1.5.0
*/
@ConfigurationProperties(prefix = "spring.kafka")
Expand Down Expand Up @@ -876,7 +877,7 @@ public enum Type {
* Whether the container should fail to start if at least one of the configured
* topics are not present on the broker.
*/
private boolean missingTopicsFatal = true;
private boolean missingTopicsFatal = false;

public Type getType() {
return this.type;
Expand Down
Expand Up @@ -86,6 +86,7 @@
* @author Stephane Nicoll
* @author Eddú Meléndez
* @author Nakul Mishra
* @author Dhiren Mathur
*/
class KafkaAutoConfigurationTests {

Expand Down Expand Up @@ -364,7 +365,7 @@ void listenerProperties() {
"spring.kafka.listener.no-poll-threshold=2.5", "spring.kafka.listener.type=batch",
"spring.kafka.listener.idle-event-interval=1s", "spring.kafka.listener.monitor-interval=45",
"spring.kafka.listener.log-container-config=true",
"spring.kafka.listener.missing-topics-fatal=false", "spring.kafka.jaas.enabled=true",
"spring.kafka.listener.missing-topics-fatal=true", "spring.kafka.jaas.enabled=true",
"spring.kafka.producer.transaction-id-prefix=foo", "spring.kafka.jaas.login-module=foo",
"spring.kafka.jaas.control-flag=REQUISITE", "spring.kafka.jaas.options.useKeyTab=true")
.run((context) -> {
Expand All @@ -389,7 +390,7 @@ void listenerProperties() {
assertThat(containerProperties.getIdleEventInterval()).isEqualTo(1000L);
assertThat(containerProperties.getMonitorInterval()).isEqualTo(45);
assertThat(containerProperties.isLogContainerConfig()).isTrue();
assertThat(containerProperties.isMissingTopicsFatal()).isFalse();
assertThat(containerProperties.isMissingTopicsFatal()).isTrue();
assertThat(ReflectionTestUtils.getField(kafkaListenerContainerFactory, "concurrency")).isEqualTo(3);
assertThat(kafkaListenerContainerFactory.isBatchListener()).isTrue();
assertThat(context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)).hasSize(1);
Expand Down Expand Up @@ -580,6 +581,17 @@ void testConcurrentKafkaListenerContainerFactoryWithCustomConsumerFactory() {
});
}

@Test
void testConcurrentKafkaListenerContainerFactoryMatchesDefaults() {
Listener listenerProperties = new KafkaProperties().getListener();
this.contextRunner.withUserConfiguration(ConsumerFactoryConfiguration.class).run((context) -> {
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context
.getBean(ConcurrentKafkaListenerContainerFactory.class);
assertThat(kafkaListenerContainerFactory.getContainerProperties().isMissingTopicsFatal())
.isEqualTo(listenerProperties.isMissingTopicsFatal());
});
}

@Configuration(proxyBeanMethods = false)
static class MessageConverterConfiguration {

Expand Down

0 comments on commit a12eace

Please sign in to comment.