From 0e07eb2393496e0248bfa02cf601b4927475345e Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 13 Mar 2022 18:48:32 +0100 Subject: [PATCH] Remove deprecated Spring Kafka's only-log-record-metadata property See gh-30089 --- ...entKafkaListenerContainerFactoryConfigurer.java | 1 - .../boot/autoconfigure/kafka/KafkaProperties.java | 14 -------------- .../additional-spring-configuration-metadata.json | 10 ++++++++++ .../kafka/KafkaAutoConfigurationTests.java | 11 ----------- .../autoconfigure/kafka/KafkaPropertiesTests.java | 3 +-- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java index 2eac0ac960..33efab12c5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java @@ -178,7 +178,6 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer { map.from(properties::getMonitorInterval).as(Duration::getSeconds).as(Number::intValue) .to(container::setMonitorInterval); map.from(properties::getLogContainerConfig).to(container::setLogContainerConfig); - map.from(properties::isOnlyLogRecordMetadata).to(container::setOnlyLogRecordMetadata); map.from(properties::isMissingTopicsFatal).to(container::setMissingTopicsFatal); map.from(properties::isImmediateStop).to(container::setStopImmediate); map.from(this.transactionManager).to(container::setTransactionManager); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java index 3d15670cef..69410bd327 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java @@ -934,12 +934,6 @@ public class KafkaProperties { */ private Boolean logContainerConfig; - /** - * Whether to suppress the entire record from being written to the log when - * retries are being attempted. - */ - private boolean onlyLogRecordMetadata = true; - /** * Whether the container should fail to start if at least one of the configured * topics are not present on the broker. @@ -1056,14 +1050,6 @@ public class KafkaProperties { this.logContainerConfig = logContainerConfig; } - public boolean isOnlyLogRecordMetadata() { - return this.onlyLogRecordMetadata; - } - - public void setOnlyLogRecordMetadata(boolean onlyLogRecordMetadata) { - this.onlyLogRecordMetadata = onlyLogRecordMetadata; - } - public boolean isMissingTopicsFatal() { return this.missingTopicsFatal; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index ec4228c95a..f6da250d6c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1503,6 +1503,16 @@ "name": "spring.kafka.jaas.control-flag", "defaultValue": "required" }, + { + "name": "spring.kafka.listener.only-log-record-metadata", + "type": "java.lang.Boolean", + "defaultValue": true, + "description": "Whether to suppress the entire record from being written to the log when retries are being attempted.", + "deprecation": { + "reason": "Use KafkaUtils#setConsumerRecordFormatter instead.", + "level": "error" + } + }, { "name": "spring.kafka.listener.type", "defaultValue": "single" 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 fe0eacbf0c..861aff1bed 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 @@ -432,17 +432,6 @@ class KafkaAutoConfigurationTests { }); } - @Test - @Deprecated - void logOnlyRecordMetadataProperty() { - this.contextRunner.withPropertyValues("spring.kafka.listener.only-log-record-metadata=true").run((context) -> { - AbstractKafkaListenerContainerFactory kafkaListenerContainerFactory = (AbstractKafkaListenerContainerFactory) context - .getBean(KafkaListenerContainerFactory.class); - ContainerProperties containerProperties = kafkaListenerContainerFactory.getContainerProperties(); - assertThat(containerProperties.isOnlyLogRecordMetadata()).isTrue(); - }); - } - @Test void testKafkaTemplateRecordMessageConverters() { this.contextRunner.withUserConfiguration(MessageConverterConfiguration.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaPropertiesTests.java index 189073952c..620e0b25ea 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,6 @@ class KafkaPropertiesTests { void listenerDefaultValuesAreConsistent() { ContainerProperties container = new ContainerProperties("test"); Listener listenerProperties = new KafkaProperties().getListener(); - assertThat(listenerProperties.isOnlyLogRecordMetadata()).isEqualTo(container.isOnlyLogRecordMetadata()); assertThat(listenerProperties.isMissingTopicsFatal()).isEqualTo(container.isMissingTopicsFatal()); }