From ea65c28bfaf4fdd4584ff5a327d983531adf4eea Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Wed, 20 Oct 2021 19:45:46 -0700 Subject: [PATCH] Polish --- .../autoconfigure/kafka/KafkaProperties.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 2a4c29626f2..e7054900f57 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 @@ -1186,14 +1186,7 @@ public class KafkaProperties { } public Map buildProperties() { - MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> { - entries.put("spring.kafka.ssl.key-store-key", this.getKeyStoreKey()); - entries.put("spring.kafka.ssl.key-store-location", this.getKeyStoreLocation()); - }); - MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> { - entries.put("spring.kafka.ssl.trust-store-certificates", this.getTrustStoreCertificates()); - entries.put("spring.kafka.ssl.trust-store-location", this.getTrustStoreLocation()); - }); + validate(); Properties properties = new Properties(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(this::getKeyPassword).to(properties.in(SslConfigs.SSL_KEY_PASSWORD_CONFIG)); @@ -1213,6 +1206,17 @@ public class KafkaProperties { return properties; } + private void validate() { + MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> { + entries.put("spring.kafka.ssl.key-store-key", this.getKeyStoreKey()); + entries.put("spring.kafka.ssl.key-store-location", this.getKeyStoreLocation()); + }); + MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> { + entries.put("spring.kafka.ssl.trust-store-certificates", this.getTrustStoreCertificates()); + entries.put("spring.kafka.ssl.trust-store-location", this.getTrustStoreLocation()); + }); + } + private String resourceToPath(Resource resource) { try { return resource.getFile().getAbsolutePath();