See gh-24837
pull/24851/head
izeye 4 years ago committed by Stephane Nicoll
parent 1a2a3d6598
commit e7350503b8

@ -124,7 +124,7 @@ public class CouchbaseAutoConfiguration {
@Bean
@ConditionalOnSingleCandidate(ObjectMapper.class)
ClusterEnvironmentBuilderCustomizer cluster(ObjectMapper objectMapper) {
ClusterEnvironmentBuilderCustomizer jacksonClusterEnvironmentBuilderCustomizer(ObjectMapper objectMapper) {
return new JacksonClusterEnvironmentBuilderCustomizer(objectMapper);
}

@ -119,10 +119,10 @@ class ElasticsearchRestClientConfigurations {
@ConditionalOnMissingBean
Sniffer elasticsearchSniffer(RestHighLevelClient client, ElasticsearchRestClientProperties properties) {
SnifferBuilder builder = Sniffer.builder(client.getLowLevelClient());
PropertyMapper get = PropertyMapper.get().alwaysApplyingWhenNonNull();
get.from(properties.getSniffer().getInterval()).asInt(Duration::toMillis)
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(properties.getSniffer().getInterval()).asInt(Duration::toMillis)
.to(builder::setSniffIntervalMillis);
get.from(properties.getSniffer().getDelayAfterFailure()).asInt(Duration::toMillis)
map.from(properties.getSniffer().getDelayAfterFailure()).asInt(Duration::toMillis)
.to(builder::setSniffAfterFailureDelayMillis);
return builder.build();
}

@ -248,15 +248,12 @@ class ElasticsearchRestClientAutoConfigurationTests {
@Test
void configureWhenCustomSnifferShouldBackOff() {
Sniffer customSniffer = mock(Sniffer.class);
this.contextRunner.withBean(Sniffer.class, () -> customSniffer)
.withPropertyValues("spring.elasticsearch.rest.sniffer.interval=180s",
"spring.elasticsearch.rest.sniffer.delay-after-failure=30s")
.run((context) -> {
assertThat(context).hasSingleBean(Sniffer.class);
Sniffer sniffer = context.getBean(Sniffer.class);
assertThat(sniffer).isSameAs(customSniffer);
verifyNoInteractions(customSniffer);
});
this.contextRunner.withBean(Sniffer.class, () -> customSniffer).run((context) -> {
assertThat(context).hasSingleBean(Sniffer.class);
Sniffer sniffer = context.getBean(Sniffer.class);
assertThat(sniffer).isSameAs(customSniffer);
verifyNoInteractions(customSniffer);
});
}
@Configuration(proxyBeanMethods = false)

Loading…
Cancel
Save