From bec40fba89bb965155527f31e156dd1b1a57264d Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Thu, 7 Sep 2023 16:54:03 -0400 Subject: [PATCH] KafkaBinderConfigurationProperties native changes - Earlier, we had to add Autowired on KafkaBinderConfigurationProperties constructor as there were some issues with runtime hints generation which caused issues when running an app in native mode. Spring Boot fixed these issues and we can remove this unnecessary Autowired from the constructor. See the following issues from Spring Boot for more details. https://github.com/spring-projects/spring-boot/issues/34507 https://github.com/spring-projects/spring-boot/issues/35564 Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2640 --- .../KafkaBinderConfigurationProperties.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/binders/kafka-binder/spring-cloud-stream-binder-kafka-core/src/main/java/org/springframework/cloud/stream/binder/kafka/properties/KafkaBinderConfigurationProperties.java b/binders/kafka-binder/spring-cloud-stream-binder-kafka-core/src/main/java/org/springframework/cloud/stream/binder/kafka/properties/KafkaBinderConfigurationProperties.java index 7cf63d6a1..13beac13f 100644 --- a/binders/kafka-binder/spring-cloud-stream-binder-kafka-core/src/main/java/org/springframework/cloud/stream/binder/kafka/properties/KafkaBinderConfigurationProperties.java +++ b/binders/kafka-binder/spring-cloud-stream-binder-kafka-core/src/main/java/org/springframework/cloud/stream/binder/kafka/properties/KafkaBinderConfigurationProperties.java @@ -36,7 +36,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.producer.ProducerConfig; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.kafka.KafkaProperties; import org.springframework.cloud.stream.binder.HeaderMode; import org.springframework.cloud.stream.binder.ProducerProperties; @@ -146,16 +145,14 @@ public class KafkaBinderConfigurationProperties { private boolean enableObservation; /** - * @Autowired on this constructor is necessary for all the properties to be discovered and bound when running as a native - * application. - * - * See the following issue for more details: - * - * https://github.com/spring-cloud/spring-cloud-stream/issues/2644 + * Earlier, @Autowired on this constructor was necessary for all the properties to be discovered + * and bound when running as a native application. However, now that Spring Boot fixed the underlying + * issue, we are removing the @Autowired from the constructor. See these Boot issues for more details. + * https://github.com/spring-projects/spring-boot/issues/34507 + * https://github.com/spring-projects/spring-boot/issues/35564 * * @param kafkaProperties Spring Kafka properties autoconfigured by Spring Boot */ - @Autowired public KafkaBinderConfigurationProperties(KafkaProperties kafkaProperties) { Assert.notNull(kafkaProperties, "'kafkaProperties' cannot be null"); this.kafkaProperties = kafkaProperties;