Merge branch '3.3.x'

Closes gh-43448
This commit is contained in:
Phillip Webb 2024-12-09 09:46:47 -08:00
commit 565ec07046
3 changed files with 27 additions and 4 deletions

View File

@ -177,6 +177,18 @@ public class KafkaProperties {
return properties; return properties;
} }
/**
* Create an initial map of consumer properties from the state of this instance.
* <p>
* This allows you to add additional properties, if necessary, and override the
* default {@code kafkaConsumerFactory} bean.
* @return the consumer properties initialized with the customizations defined on this
* instance
*/
public Map<String, Object> buildConsumerProperties() {
return buildConsumerProperties(null);
}
/** /**
* Create an initial map of consumer properties from the state of this instance. * Create an initial map of consumer properties from the state of this instance.
* <p> * <p>
@ -192,6 +204,18 @@ public class KafkaProperties {
return properties; return properties;
} }
/**
* Create an initial map of producer properties from the state of this instance.
* <p>
* This allows you to add additional properties, if necessary, and override the
* default {@code kafkaProducerFactory} bean.
* @return the producer properties initialized with the customizations defined on this
* instance
*/
public Map<String, Object> buildProducerProperties() {
return buildProducerProperties(null);
}
/** /**
* Create an initial map of producer properties from the state of this instance. * Create an initial map of producer properties from the state of this instance.
* <p> * <p>

View File

@ -36,7 +36,6 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
* @author Madhura Bhave * @author Madhura Bhave
* @since 2.1.0 * @since 2.1.0
*/ */
public class ClientsConfiguredCondition extends SpringBootCondition { public class ClientsConfiguredCondition extends SpringBootCondition {
private static final Bindable<Map<String, OAuth2ClientProperties.Registration>> STRING_REGISTRATION_MAP = Bindable private static final Bindable<Map<String, OAuth2ClientProperties.Registration>> STRING_REGISTRATION_MAP = Bindable

View File

@ -80,7 +80,7 @@ class KafkaPropertiesTests {
properties.getSsl().setKeyStoreKey("-----BEGINkey"); properties.getSsl().setKeyStoreKey("-----BEGINkey");
properties.getSsl().setTrustStoreCertificates("-----BEGINtrust"); properties.getSsl().setTrustStoreCertificates("-----BEGINtrust");
properties.getSsl().setKeyStoreCertificateChain("-----BEGINchain"); properties.getSsl().setKeyStoreCertificateChain("-----BEGINchain");
Map<String, Object> consumerProperties = properties.buildConsumerProperties(null); Map<String, Object> consumerProperties = properties.buildConsumerProperties();
assertThat(consumerProperties).containsEntry(SslConfigs.SSL_KEYSTORE_KEY_CONFIG, "-----BEGINkey"); assertThat(consumerProperties).containsEntry(SslConfigs.SSL_KEYSTORE_KEY_CONFIG, "-----BEGINkey");
assertThat(consumerProperties).containsEntry(SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG, "-----BEGINtrust"); assertThat(consumerProperties).containsEntry(SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG, "-----BEGINtrust");
assertThat(consumerProperties).containsEntry(SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG, assertThat(consumerProperties).containsEntry(SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG,
@ -103,7 +103,7 @@ class KafkaPropertiesTests {
properties.getSsl().setKeyStoreKey("-----BEGIN"); properties.getSsl().setKeyStoreKey("-----BEGIN");
properties.getSsl().setKeyStoreLocation(new ClassPathResource("ksLoc")); properties.getSsl().setKeyStoreLocation(new ClassPathResource("ksLoc"));
assertThatExceptionOfType(MutuallyExclusiveConfigurationPropertiesException.class) assertThatExceptionOfType(MutuallyExclusiveConfigurationPropertiesException.class)
.isThrownBy(() -> properties.buildConsumerProperties(null)); .isThrownBy(() -> properties.buildConsumerProperties());
} }
@Test @Test
@ -112,7 +112,7 @@ class KafkaPropertiesTests {
properties.getSsl().setTrustStoreLocation(new ClassPathResource("tsLoc")); properties.getSsl().setTrustStoreLocation(new ClassPathResource("tsLoc"));
properties.getSsl().setTrustStoreCertificates("-----BEGIN"); properties.getSsl().setTrustStoreCertificates("-----BEGIN");
assertThatExceptionOfType(MutuallyExclusiveConfigurationPropertiesException.class) assertThatExceptionOfType(MutuallyExclusiveConfigurationPropertiesException.class)
.isThrownBy(() -> properties.buildConsumerProperties(null)); .isThrownBy(() -> properties.buildConsumerProperties());
} }
@Test @Test