Formatting
This commit is contained in:
parent
42c053cf1b
commit
7b120c1c97
|
|
@ -97,10 +97,9 @@ class OnEnabledEndpointCondition extends SpringBootCondition {
|
|||
return getEndpointAttributes(endpointType);
|
||||
}
|
||||
|
||||
private Class<?> getEndpointType(ConditionContext context,
|
||||
MethodMetadata metadata) {
|
||||
Map<String, Object> attributes = metadata.getAnnotationAttributes(
|
||||
ConditionalOnEnabledEndpoint.class.getName());
|
||||
private Class<?> getEndpointType(ConditionContext context, MethodMetadata metadata) {
|
||||
Map<String, Object> attributes = metadata
|
||||
.getAnnotationAttributes(ConditionalOnEnabledEndpoint.class.getName());
|
||||
if (attributes != null && attributes.containsKey("endpoint")) {
|
||||
Class<?> target = (Class<?>) attributes.get("endpoint");
|
||||
if (target != Void.class) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ import org.springframework.integration.support.channel.HeaderChannelRegistry;
|
|||
import org.springframework.integration.support.management.graph.IntegrationGraphServer;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the {@link IntegrationGraphEndpoint}.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for the
|
||||
* {@link IntegrationGraphEndpoint}.
|
||||
*
|
||||
* @author Tim Ysewyn
|
||||
* @author Stephane Nicoll
|
||||
|
|
@ -58,4 +59,3 @@ public class IntegrationGraphEndpointAutoConfiguration {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,20 +37,21 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation
|
||||
* of {@link org.springframework.web.reactive.function.client.WebClient}.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation of
|
||||
* {@link org.springframework.web.reactive.function.client.WebClient}.
|
||||
*
|
||||
* <p>This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter}
|
||||
* defined in {@link RestTemplateMetricsAutoConfiguration} for limiting the
|
||||
* cardinality of "uri" tags.
|
||||
* <p>
|
||||
* This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter} defined in
|
||||
* {@link RestTemplateMetricsAutoConfiguration} for limiting the cardinality of "uri"
|
||||
* tags.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(WebClient.class)
|
||||
@AutoConfigureAfter({MetricsAutoConfiguration.class,
|
||||
SimpleMetricsExportAutoConfiguration.class})
|
||||
@AutoConfigureAfter({ MetricsAutoConfiguration.class,
|
||||
SimpleMetricsExportAutoConfiguration.class })
|
||||
@AutoConfigureBefore(WebClientAutoConfiguration.class)
|
||||
@ConditionalOnBean(MeterRegistry.class)
|
||||
public class WebClientMetricsAutoConfiguration {
|
||||
|
|
@ -62,8 +63,8 @@ public class WebClientMetricsAutoConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public MetricsWebClientCustomizer metricsWebClientCustomizer(MeterRegistry meterRegistry,
|
||||
WebClientExchangeTagsProvider tagsProvider,
|
||||
public MetricsWebClientCustomizer metricsWebClientCustomizer(
|
||||
MeterRegistry meterRegistry, WebClientExchangeTagsProvider tagsProvider,
|
||||
MetricsProperties properties) {
|
||||
return new MetricsWebClientCustomizer(meterRegistry, tagsProvider,
|
||||
properties.getWeb().getClient().getRequestsMetricName());
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation
|
||||
* of Spring WebFlux applications.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation of Spring
|
||||
* WebFlux applications.
|
||||
*
|
||||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
|
|
|
|||
|
|
@ -42,15 +42,14 @@ public class CachesEndpointAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void runShouldHaveEndpointBean() {
|
||||
this.contextRunner.withUserConfiguration(CacheConfiguration.class)
|
||||
.run((context) ->
|
||||
assertThat(context).hasSingleBean(CachesEndpoint.class));
|
||||
this.contextRunner.withUserConfiguration(CacheConfiguration.class).run(
|
||||
(context) -> assertThat(context).hasSingleBean(CachesEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWithoutCacheManagerShouldHaveEndpointBean() {
|
||||
this.contextRunner.run((context) ->
|
||||
assertThat(context).hasSingleBean(CachesEndpoint.class));
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(CachesEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
|
||||
@Test
|
||||
public void outcomeWithReferenceWhenNoPropertiesShouldMatch() {
|
||||
this.contextRunner.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
|
||||
ComponentEnabledIfEndpointIsEnabledConfiguration.class).run((context) ->
|
||||
assertThat(context).hasBean("fooComponent"));
|
||||
this.contextRunner
|
||||
.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
|
||||
ComponentEnabledIfEndpointIsEnabledConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasBean("fooComponent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -114,8 +115,7 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=true")
|
||||
.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
|
||||
ComponentEnabledIfEndpointIsEnabledConfiguration.class)
|
||||
.run((context) ->
|
||||
assertThat(context).hasBean("fooComponent"));
|
||||
.run((context) -> assertThat(context).hasBean("fooComponent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -123,22 +123,23 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=false")
|
||||
.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class,
|
||||
ComponentEnabledIfEndpointIsEnabledConfiguration.class)
|
||||
.run((context) ->
|
||||
assertThat(context).doesNotHaveBean("fooComponent"));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("fooComponent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWithNoReferenceShouldFail() {
|
||||
this.contextRunner.withUserConfiguration(
|
||||
ComponentWithNoEndpointReferenceConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure().getCause().getMessage()).contains(
|
||||
"No endpoint is specified and the return type of the @Bean method "
|
||||
+ "is neither an @Endpoint, nor an @EndpointExtension");
|
||||
});
|
||||
this.contextRunner
|
||||
.withUserConfiguration(
|
||||
ComponentWithNoEndpointReferenceConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure().getCause().getMessage())
|
||||
.contains(
|
||||
"No endpoint is specified and the return type of the @Bean method "
|
||||
+ "is neither an @Endpoint, nor an @EndpointExtension");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Endpoint(id = "foo", enableByDefault = true)
|
||||
static class FooEndpointEnabledByDefaultTrue {
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
|
||||
/**
|
||||
* Tests for generating documentation describing the {@link CachesEndpoint}
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
|
||||
|
|
@ -52,11 +53,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
|
|||
private static final List<FieldDescriptor> levelFields = Arrays.asList(
|
||||
fieldWithPath("name").description("Cache name."),
|
||||
fieldWithPath("cacheManager").description("Cache manager name."),
|
||||
fieldWithPath("target").description(
|
||||
"Fully qualified name of the native cache."));
|
||||
fieldWithPath("target")
|
||||
.description("Fully qualified name of the native cache."));
|
||||
|
||||
private static final List<ParameterDescriptor> requestParameters = Collections.singletonList(
|
||||
parameterWithName("cacheManager")
|
||||
private static final List<ParameterDescriptor> requestParameters = Collections
|
||||
.singletonList(parameterWithName("cacheManager")
|
||||
.description("Name of the cacheManager to qualify the cache. May be "
|
||||
+ "omitted if the cache name is unique.")
|
||||
.optional());
|
||||
|
|
@ -67,12 +68,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
|
|||
.andDo(MockMvcRestDocumentation.document("caches/all", responseFields(
|
||||
fieldWithPath("cacheManagers")
|
||||
.description("Cache managers keyed by id."),
|
||||
fieldWithPath("cacheManagers.*")
|
||||
.description("Caches in the application context keyed by "
|
||||
+ "name."))
|
||||
.andWithPrefix("cacheManagers.*.*.", fieldWithPath("target")
|
||||
.description(
|
||||
"Fully qualified name of the native cache."))));
|
||||
fieldWithPath("cacheManagers.*").description(
|
||||
"Caches in the application context keyed by " + "name."))
|
||||
.andWithPrefix("cacheManagers.*.*.",
|
||||
fieldWithPath("target").description(
|
||||
"Fully qualified name of the native cache."))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -91,14 +91,14 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
|
|||
|
||||
@Test
|
||||
public void evictNamedCache() throws Exception {
|
||||
this.mockMvc.perform(
|
||||
delete("/actuator/caches/countries?cacheManager=anotherCacheManager"))
|
||||
.andExpect(status().isNoContent()).andDo(
|
||||
MockMvcRestDocumentation.document("caches/evict-named",
|
||||
this.mockMvc
|
||||
.perform(delete(
|
||||
"/actuator/caches/countries?cacheManager=anotherCacheManager"))
|
||||
.andExpect(status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("caches/evict-named",
|
||||
requestParameters(requestParameters)));
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@Import(BaseDocumentationConfiguration.class)
|
||||
static class TestConfiguration {
|
||||
|
|
@ -106,10 +106,10 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati
|
|||
@Bean
|
||||
public CachesEndpoint endpoint() {
|
||||
Map<String, CacheManager> cacheManagers = new HashMap<>();
|
||||
cacheManagers.put("cacheManager", new ConcurrentMapCacheManager(
|
||||
"countries", "cities"));
|
||||
cacheManagers.put("anotherCacheManager", new ConcurrentMapCacheManager(
|
||||
"countries"));
|
||||
cacheManagers.put("cacheManager",
|
||||
new ConcurrentMapCacheManager("countries", "cities"));
|
||||
cacheManagers.put("anotherCacheManager",
|
||||
new ConcurrentMapCacheManager("countries"));
|
||||
return new CachesEndpoint(cacheManagers);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
*
|
||||
* @author Tim Ysewyn
|
||||
*/
|
||||
public class IntegrationGraphEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
|
||||
public class IntegrationGraphEndpointDocumentationTests
|
||||
extends MockMvcEndpointDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void graph() throws Exception {
|
||||
|
|
@ -45,8 +46,8 @@ public class IntegrationGraphEndpointDocumentationTests extends MockMvcEndpointD
|
|||
|
||||
@Test
|
||||
public void rebuild() throws Exception {
|
||||
this.mockMvc.perform(post("/actuator/integrationgraph")).andExpect(status()
|
||||
.isNoContent())
|
||||
this.mockMvc.perform(post("/actuator/integrationgraph"))
|
||||
.andExpect(status().isNoContent())
|
||||
.andDo(MockMvcRestDocumentation.document("integrationgraph/rebuild"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ public class IntegrationGraphEndpointAutoConfigurationTests {
|
|||
@Test
|
||||
public void runWhenSpringIntegrationIsNotEnabledShouldNotHaveEndpointBean() {
|
||||
ApplicationContextRunner noSpringIntegrationRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
IntegrationGraphEndpointAutoConfiguration.class));
|
||||
.withConfiguration(AutoConfigurations
|
||||
.of(IntegrationGraphEndpointAutoConfiguration.class));
|
||||
noSpringIntegrationRunner.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(IntegrationGraphEndpoint.class);
|
||||
assertThat(context).doesNotHaveBean(IntegrationGraphServer.class);
|
||||
|
|
|
|||
|
|
@ -90,8 +90,9 @@ public class HibernateMetricsAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void entityManagerFactoryInstrumentationCanBeDisabled() {
|
||||
this.contextRunner.withPropertyValues("management.metrics.enable.hibernate=false",
|
||||
"spring.jpa.properties.hibernate.generate_statistics:true")
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.metrics.enable.hibernate=false",
|
||||
"spring.jpa.properties.hibernate.generate_statistics:true")
|
||||
.run((context) -> {
|
||||
context.getBean(EntityManagerFactory.class)
|
||||
.unwrap(SessionFactory.class);
|
||||
|
|
@ -130,7 +131,7 @@ public class HibernateMetricsAutoConfigurationTests {
|
|||
// ensure EntityManagerFactory is not an Hibernate SessionFactory
|
||||
assertThatThrownBy(() -> context.getBean(EntityManagerFactory.class)
|
||||
.unwrap(SessionFactory.class))
|
||||
.isInstanceOf(PersistenceException.class);
|
||||
.isInstanceOf(PersistenceException.class);
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
assertThat(registry.find("hibernate.statements").meter()).isNull();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -78,25 +78,27 @@ public class RestTemplateMetricsAutoConfigurationTests {
|
|||
this.contextRunner
|
||||
.withPropertyValues("management.metrics.web.client.max-uri-tags=10")
|
||||
.run((context) -> {
|
||||
MetricsProperties properties = context.getBean(MetricsProperties.class);
|
||||
int maxUriTags = properties.getWeb().getClient().getMaxUriTags();
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
RestTemplate restTemplate = context.getBean(RestTemplateBuilder.class)
|
||||
.build();
|
||||
MockRestServiceServer server = MockRestServiceServer
|
||||
.createServer(restTemplate);
|
||||
for (int i = 0; i < maxUriTags + 10; i++) {
|
||||
server.expect(requestTo("/test/" + i))
|
||||
.andRespond(withStatus(HttpStatus.OK));
|
||||
}
|
||||
for (int i = 0; i < maxUriTags + 10; i++) {
|
||||
restTemplate.getForObject("/test/" + i, String.class);
|
||||
}
|
||||
assertThat(registry.get("http.client.requests").meters()).hasSize(maxUriTags);
|
||||
assertThat(this.out.toString())
|
||||
.contains("Reached the maximum number of URI tags "
|
||||
+ "for 'http.client.requests'");
|
||||
});
|
||||
MetricsProperties properties = context
|
||||
.getBean(MetricsProperties.class);
|
||||
int maxUriTags = properties.getWeb().getClient().getMaxUriTags();
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
RestTemplate restTemplate = context.getBean(RestTemplateBuilder.class)
|
||||
.build();
|
||||
MockRestServiceServer server = MockRestServiceServer
|
||||
.createServer(restTemplate);
|
||||
for (int i = 0; i < maxUriTags + 10; i++) {
|
||||
server.expect(requestTo("/test/" + i))
|
||||
.andRespond(withStatus(HttpStatus.OK));
|
||||
}
|
||||
for (int i = 0; i < maxUriTags + 10; i++) {
|
||||
restTemplate.getForObject("/test/" + i, String.class);
|
||||
}
|
||||
assertThat(registry.get("http.client.requests").meters())
|
||||
.hasSize(maxUriTags);
|
||||
assertThat(this.out.toString())
|
||||
.contains("Reached the maximum number of URI tags "
|
||||
+ "for 'http.client.requests'");
|
||||
});
|
||||
}
|
||||
|
||||
private void validateRestTemplate(RestTemplate restTemplate, MeterRegistry registry) {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ public class WebClientMetricsAutoConfigurationTests {
|
|||
public WebClientExchangeTagsProvider customTagProvider() {
|
||||
return mock(WebClientExchangeTagsProvider.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,5 +65,7 @@ public class WebFluxMetricsAutoConfigurationTests {
|
|||
public WebFluxTagsProvider customWebFluxTagsProvider() {
|
||||
return mock(WebFluxTagsProvider.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ public class CachesEndpoint {
|
|||
*/
|
||||
@ReadOperation
|
||||
public CacheEntry cache(@Selector String cache, @Nullable String cacheManager) {
|
||||
return extractUniqueCacheEntry(cache, getCacheEntries(
|
||||
(name) -> name.equals(cache), safeEqual(cacheManager)));
|
||||
return extractUniqueCacheEntry(cache,
|
||||
getCacheEntries((name) -> name.equals(cache), safeEqual(cacheManager)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,23 +95,23 @@ public class CachesEndpoint {
|
|||
* Clear the specific {@link Cache}.
|
||||
* @param cache then name of the cache
|
||||
* @param cacheManager the name of the cacheManager (can be {@code null}
|
||||
* @return {@code true} if the cache was cleared or {@code false} if no such cache exists
|
||||
* @return {@code true} if the cache was cleared or {@code false} if no such cache
|
||||
* exists
|
||||
* @throws NonUniqueCacheException if more than one cache with that name exist and no
|
||||
*/
|
||||
@DeleteOperation
|
||||
public boolean clearCache(@Selector String cache, @Nullable String cacheManager) {
|
||||
CacheEntry entry = extractUniqueCacheEntry(cache, getCacheEntries(
|
||||
(name) -> name.equals(cache), safeEqual(cacheManager)));
|
||||
CacheEntry entry = extractUniqueCacheEntry(cache,
|
||||
getCacheEntries((name) -> name.equals(cache), safeEqual(cacheManager)));
|
||||
return (entry != null && clearCache(entry));
|
||||
}
|
||||
|
||||
private List<CacheEntry> getCacheEntries(
|
||||
Predicate<String> cacheNamePredicate,
|
||||
private List<CacheEntry> getCacheEntries(Predicate<String> cacheNamePredicate,
|
||||
Predicate<String> cacheManagerNamePredicate) {
|
||||
List<CacheEntry> entries = new ArrayList<>();
|
||||
this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate)
|
||||
.forEach((cacheManagerName) -> entries.addAll(
|
||||
getCacheEntries(cacheManagerName, cacheNamePredicate)));
|
||||
.forEach((cacheManagerName) -> entries
|
||||
.addAll(getCacheEntries(cacheManagerName, cacheNamePredicate)));
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
|
@ -121,17 +121,15 @@ public class CachesEndpoint {
|
|||
List<CacheEntry> entries = new ArrayList<>();
|
||||
cacheManager.getCacheNames().stream().filter(cacheNamePredicate)
|
||||
.map(cacheManager::getCache).filter(Objects::nonNull)
|
||||
.forEach((cache) -> entries.add(
|
||||
new CacheEntry(cache, cacheManagerName)));
|
||||
.forEach((cache) -> entries.add(new CacheEntry(cache, cacheManagerName)));
|
||||
return entries;
|
||||
}
|
||||
|
||||
private CacheEntry extractUniqueCacheEntry(String cache,
|
||||
List<CacheEntry> entries) {
|
||||
private CacheEntry extractUniqueCacheEntry(String cache, List<CacheEntry> entries) {
|
||||
if (entries.size() > 1) {
|
||||
throw new NonUniqueCacheException(cache, entries.stream()
|
||||
.map(CacheEntry::getCacheManager).distinct()
|
||||
.collect(Collectors.toList()));
|
||||
throw new NonUniqueCacheException(cache,
|
||||
entries.stream().map(CacheEntry::getCacheManager).distinct()
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
return (entries.isEmpty() ? null : entries.get(0));
|
||||
}
|
||||
|
|
@ -152,8 +150,8 @@ public class CachesEndpoint {
|
|||
}
|
||||
|
||||
/**
|
||||
* A report of available {@link Cache caches}, primarily intended for serialization
|
||||
* to JSON.
|
||||
* A report of available {@link Cache caches}, primarily intended for serialization to
|
||||
* JSON.
|
||||
*/
|
||||
public static final class CachesReport {
|
||||
|
||||
|
|
|
|||
|
|
@ -47,4 +47,5 @@ public class DefaultWebClientExchangeTagsProvider
|
|||
WebClientExchangeTags.status(throwable));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
|||
import org.springframework.web.reactive.function.client.ExchangeFunction;
|
||||
|
||||
/**
|
||||
* {@link ExchangeFilterFunction} applied via a
|
||||
* {@link MetricsWebClientCustomizer} to record metrics.
|
||||
* {@link ExchangeFilterFunction} applied via a {@link MetricsWebClientCustomizer} to
|
||||
* record metrics.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 2.1.0
|
||||
|
|
@ -58,8 +58,7 @@ public class MetricsWebClientFilterFunction implements ExchangeFilterFunction {
|
|||
.doOnSuccessOrError((clientResponse, throwable) -> {
|
||||
Iterable<Tag> tags = this.tagProvider.tags(clientRequest,
|
||||
clientResponse, throwable);
|
||||
Timer.builder(this.metricName)
|
||||
.tags(tags)
|
||||
Timer.builder(this.metricName).tags(tags)
|
||||
.description("Timer of WebClient operation")
|
||||
.register(this.meterRegistry)
|
||||
.record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ import org.springframework.web.reactive.function.client.WebClient;
|
|||
*/
|
||||
public final class WebClientExchangeTags {
|
||||
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName()
|
||||
+ ".uriTemplate";
|
||||
|
||||
private static final Tag IO_ERROR = Tag.of("status", "IO_ERROR");
|
||||
|
||||
|
|
@ -44,8 +45,8 @@ public final class WebClientExchangeTags {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code method} {@code Tag} for the
|
||||
* {@link ClientHttpRequest#getMethod() method} of the given {@code request}.
|
||||
* Creates a {@code method} {@code Tag} for the {@link ClientHttpRequest#getMethod()
|
||||
* method} of the given {@code request}.
|
||||
* @param request the request
|
||||
* @return the method tag
|
||||
*/
|
||||
|
|
@ -80,8 +81,8 @@ public final class WebClientExchangeTags {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code status} {@code Tag} derived from the
|
||||
* exception thrown by the client.
|
||||
* Creates a {@code status} {@code Tag} derived from the exception thrown by the
|
||||
* client.
|
||||
* @param throwable the exception
|
||||
* @return the status tag
|
||||
*/
|
||||
|
|
@ -90,9 +91,9 @@ public final class WebClientExchangeTags {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a {@code clientName} {@code Tag} derived from
|
||||
* the {@link java.net.URI#getHost host}
|
||||
* of the {@link ClientRequest#url() URL} of the given {@code request}.
|
||||
* Create a {@code clientName} {@code Tag} derived from the
|
||||
* {@link java.net.URI#getHost host} of the {@link ClientRequest#url() URL} of the
|
||||
* given {@code request}.
|
||||
* @param request the request
|
||||
* @return the clientName tag
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,5 +38,7 @@ public interface WebClientExchangeTagsProvider {
|
|||
* @param throwable the exception (may be {@code null})
|
||||
* @return tags to associate with metrics for the request and response exchange
|
||||
*/
|
||||
Iterable<Tag> tags(ClientRequest request, ClientResponse response, Throwable throwable);
|
||||
Iterable<Tag> tags(ClientRequest request, ClientResponse response,
|
||||
Throwable throwable);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Actuator support for
|
||||
* {@link org.springframework.web.reactive.function.client.WebClient} metrics.
|
||||
* Actuator support for {@link org.springframework.web.reactive.function.client.WebClient}
|
||||
* metrics.
|
||||
*/
|
||||
package org.springframework.boot.actuate.metrics.web.reactive.client;
|
||||
|
|
|
|||
|
|
@ -51,17 +51,17 @@ public class CachesEndpointTests {
|
|||
|
||||
@Test
|
||||
public void allCachesWithSingleCacheManager() {
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", new ConcurrentMapCacheManager("a", "b")));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test",
|
||||
new ConcurrentMapCacheManager("a", "b")));
|
||||
Map<String, Map<String, CacheDescriptor>> allDescriptors = endpoint.caches()
|
||||
.getCacheManagers();
|
||||
assertThat(allDescriptors).containsOnlyKeys("test");
|
||||
Map<String, CacheDescriptor> descriptors = allDescriptors.get("test");
|
||||
assertThat(descriptors).containsOnlyKeys("a", "b");
|
||||
assertThat(descriptors.get("a").getTarget()).isEqualTo(
|
||||
ConcurrentHashMap.class.getName());
|
||||
assertThat(descriptors.get("b").getTarget()).isEqualTo(
|
||||
ConcurrentHashMap.class.getName());
|
||||
assertThat(descriptors.get("a").getTarget())
|
||||
.isEqualTo(ConcurrentHashMap.class.getName());
|
||||
assertThat(descriptors.get("b").getTarget())
|
||||
.isEqualTo(ConcurrentHashMap.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -79,8 +79,8 @@ public class CachesEndpointTests {
|
|||
|
||||
@Test
|
||||
public void namedCacheWithSingleCacheManager() {
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", new ConcurrentMapCacheManager("b", "a")));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test",
|
||||
new ConcurrentMapCacheManager("b", "a")));
|
||||
CacheEntry entry = endpoint.cache("a", null);
|
||||
assertThat(entry).isNotNull();
|
||||
assertThat(entry.getCacheManager()).isEqualTo("test");
|
||||
|
|
@ -103,8 +103,8 @@ public class CachesEndpointTests {
|
|||
|
||||
@Test
|
||||
public void namedCacheWithUnknownCache() {
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", new ConcurrentMapCacheManager("b", "a")));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test",
|
||||
new ConcurrentMapCacheManager("b", "a")));
|
||||
CacheEntry entry = endpoint.cache("unknown", null);
|
||||
assertThat(entry).isNull();
|
||||
}
|
||||
|
|
@ -135,8 +135,8 @@ public class CachesEndpointTests {
|
|||
public void clearAllCaches() {
|
||||
Cache a = mockCache("a");
|
||||
Cache b = mockCache("b");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", cacheManager(a, b)));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(
|
||||
Collections.singletonMap("test", cacheManager(a, b)));
|
||||
endpoint.clearCaches();
|
||||
verify(a).clear();
|
||||
verify(b).clear();
|
||||
|
|
@ -146,8 +146,8 @@ public class CachesEndpointTests {
|
|||
public void clearCache() {
|
||||
Cache a = mockCache("a");
|
||||
Cache b = mockCache("b");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", cacheManager(a, b)));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(
|
||||
Collections.singletonMap("test", cacheManager(a, b)));
|
||||
assertThat(endpoint.clearCache("a", null)).isTrue();
|
||||
verify(a).clear();
|
||||
verify(b, never()).clear();
|
||||
|
|
@ -184,8 +184,8 @@ public class CachesEndpointTests {
|
|||
@Test
|
||||
public void clearCacheWithUnknownCache() {
|
||||
Cache a = mockCache("a");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", cacheManager(a)));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(
|
||||
Collections.singletonMap("test", cacheManager(a)));
|
||||
assertThat(endpoint.clearCache("unknown", null)).isFalse();
|
||||
verify(a, never()).clear();
|
||||
}
|
||||
|
|
@ -193,8 +193,8 @@ public class CachesEndpointTests {
|
|||
@Test
|
||||
public void clearCacheWithUnknownCacheManager() {
|
||||
Cache a = mockCache("a");
|
||||
CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap(
|
||||
"test", cacheManager(a)));
|
||||
CachesEndpoint endpoint = new CachesEndpoint(
|
||||
Collections.singletonMap("test", cacheManager(a)));
|
||||
assertThat(endpoint.clearCache("a", "unknown")).isFalse();
|
||||
verify(a, never()).clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link CachesEndpoint} exposed by Jersey, Spring MVC, and WebFlux.
|
||||
* Integration tests for {@link CachesEndpoint} exposed by Jersey, Spring MVC, and
|
||||
* WebFlux.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
|
@ -48,23 +49,22 @@ public class CachesEndpointWebIntegrationTests {
|
|||
@Test
|
||||
public void allCaches() {
|
||||
client.get().uri("/actuator/caches").exchange().expectStatus().isOk().expectBody()
|
||||
.jsonPath("cacheManagers.one.a.target").isEqualTo(
|
||||
ConcurrentHashMap.class.getName())
|
||||
.jsonPath("cacheManagers.one.b.target").isEqualTo(
|
||||
ConcurrentHashMap.class.getName())
|
||||
.jsonPath("cacheManagers.two.a.target").isEqualTo(
|
||||
ConcurrentHashMap.class.getName())
|
||||
.jsonPath("cacheManagers.two.c.target").isEqualTo(
|
||||
ConcurrentHashMap.class.getName());
|
||||
.jsonPath("cacheManagers.one.a.target")
|
||||
.isEqualTo(ConcurrentHashMap.class.getName())
|
||||
.jsonPath("cacheManagers.one.b.target")
|
||||
.isEqualTo(ConcurrentHashMap.class.getName())
|
||||
.jsonPath("cacheManagers.two.a.target")
|
||||
.isEqualTo(ConcurrentHashMap.class.getName())
|
||||
.jsonPath("cacheManagers.two.c.target")
|
||||
.isEqualTo(ConcurrentHashMap.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namedCache() {
|
||||
client.get().uri("/actuator/caches/b").exchange().expectStatus().isOk()
|
||||
.expectBody()
|
||||
.jsonPath("name").isEqualTo("b")
|
||||
.jsonPath("cacheManager").isEqualTo("one")
|
||||
.jsonPath("target").isEqualTo(ConcurrentHashMap.class.getName());
|
||||
.expectBody().jsonPath("name").isEqualTo("b").jsonPath("cacheManager")
|
||||
.isEqualTo("one").jsonPath("target")
|
||||
.isEqualTo(ConcurrentHashMap.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -75,8 +75,7 @@ public class CachesEndpointWebIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void namedCacheWithNonUniqueName() {
|
||||
client.get().uri("/actuator/caches/a").exchange().expectStatus()
|
||||
.isBadRequest();
|
||||
client.get().uri("/actuator/caches/a").exchange().expectStatus().isBadRequest();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -95,11 +94,9 @@ public class CachesEndpointWebIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void clearNamedCacheWithNonUniqueName() {
|
||||
client.get().uri("/actuator/caches/a").exchange().expectStatus()
|
||||
.isBadRequest();
|
||||
client.get().uri("/actuator/caches/a").exchange().expectStatus().isBadRequest();
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class TestConfiguration {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ import org.springframework.integration.support.management.graph.IntegrationGraph
|
|||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link IntegrationGraphEndpoint} exposed by Jersey, Spring MVC, and WebFlux.
|
||||
* Integration tests for {@link IntegrationGraphEndpoint} exposed by Jersey, Spring MVC,
|
||||
* and WebFlux.
|
||||
*
|
||||
* @author Tim Ysewyn
|
||||
*/
|
||||
|
|
@ -39,8 +40,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void graph() {
|
||||
client.get().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON).exchange()
|
||||
.expectStatus().isOk().expectBody()
|
||||
client.get().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange().expectStatus().isOk().expectBody()
|
||||
.jsonPath("contentDescriptor.providerVersion").isNotEmpty()
|
||||
.jsonPath("contentDescriptor.providerFormatVersion").isEqualTo(1.0f)
|
||||
.jsonPath("contentDescriptor.provider").isEqualTo("spring-integration");
|
||||
|
|
@ -48,8 +49,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
|
|||
|
||||
@Test
|
||||
public void rebuild() {
|
||||
client.post().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON).exchange()
|
||||
.expectStatus().isNoContent();
|
||||
client.post().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange().expectStatus().isNoContent();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
@ -57,7 +58,8 @@ public class IntegrationGraphEndpointWebIntegrationTests {
|
|||
public static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
public IntegrationGraphEndpoint endpoint(IntegrationGraphServer integrationGraphServer) {
|
||||
public IntegrationGraphEndpoint endpoint(
|
||||
IntegrationGraphServer integrationGraphServer) {
|
||||
return new IntegrationGraphEndpoint(integrationGraphServer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.actuate.metrics.web.reactive.client;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
|
|
@ -41,7 +40,8 @@ import static org.mockito.Mockito.mock;
|
|||
*/
|
||||
public class DefaultWebClientExchangeTagsProviderTests {
|
||||
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName()
|
||||
+ ".uriTemplate";
|
||||
|
||||
private WebClientExchangeTagsProvider tagsProvider = new DefaultWebClientExchangeTagsProvider();
|
||||
|
||||
|
|
@ -52,8 +52,10 @@ public class DefaultWebClientExchangeTagsProviderTests {
|
|||
@Before
|
||||
public void setup() {
|
||||
this.request = ClientRequest
|
||||
.create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot"))
|
||||
.attribute(URI_TEMPLATE_ATTRIBUTE, "http://example.org/projects/{project}")
|
||||
.create(HttpMethod.GET,
|
||||
URI.create("http://example.org/projects/spring-boot"))
|
||||
.attribute(URI_TEMPLATE_ATTRIBUTE,
|
||||
"http://example.org/projects/{project}")
|
||||
.build();
|
||||
this.response = mock(ClientResponse.class);
|
||||
given(this.response.statusCode()).willReturn(HttpStatus.OK);
|
||||
|
|
@ -62,38 +64,37 @@ public class DefaultWebClientExchangeTagsProviderTests {
|
|||
@Test
|
||||
public void tagsShouldBePopulated() {
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(this.request, this.response, null);
|
||||
assertThat(tags).containsExactlyInAnyOrder(
|
||||
Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
|
||||
Tag.of("clientName", "example.org"), Tag.of("status", "200"));
|
||||
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"),
|
||||
Tag.of("uri", "/projects/{project}"), Tag.of("clientName", "example.org"),
|
||||
Tag.of("status", "200"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tagsWhenNoUriTemplateShouldProvideUriPath() {
|
||||
ClientRequest request = ClientRequest
|
||||
.create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot"))
|
||||
.build();
|
||||
ClientRequest request = ClientRequest.create(HttpMethod.GET,
|
||||
URI.create("http://example.org/projects/spring-boot")).build();
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(request, this.response, null);
|
||||
assertThat(tags).containsExactlyInAnyOrder(
|
||||
Tag.of("method", "GET"), Tag.of("uri", "/projects/spring-boot"),
|
||||
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"),
|
||||
Tag.of("uri", "/projects/spring-boot"),
|
||||
Tag.of("clientName", "example.org"), Tag.of("status", "200"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tagsWhenIoExceptionShouldReturnIoErrorStatus() {
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(this.request,
|
||||
null, new IOException());
|
||||
assertThat(tags).containsExactlyInAnyOrder(
|
||||
Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
|
||||
Tag.of("clientName", "example.org"), Tag.of("status", "IO_ERROR"));
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null,
|
||||
new IOException());
|
||||
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"),
|
||||
Tag.of("uri", "/projects/{project}"), Tag.of("clientName", "example.org"),
|
||||
Tag.of("status", "IO_ERROR"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tagsWhenExceptionShouldReturnClientErrorStatus() {
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(this.request,
|
||||
null, new IllegalArgumentException());
|
||||
assertThat(tags).containsExactlyInAnyOrder(
|
||||
Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
|
||||
Tag.of("clientName", "example.org"), Tag.of("status", "CLIENT_ERROR"));
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null,
|
||||
new IllegalArgumentException());
|
||||
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"),
|
||||
Tag.of("uri", "/projects/{project}"), Tag.of("clientName", "example.org"),
|
||||
Tag.of("status", "CLIENT_ERROR"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,5 @@ public class MetricsWebClientCustomizerTests {
|
|||
this.clientBuilder.filters((filters) -> assertThat(filters).hasSize(1).first()
|
||||
.isInstanceOf(MetricsWebClientFilterFunction.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ import static org.mockito.Mockito.mock;
|
|||
*/
|
||||
public class WebClientExchangeTagsTests {
|
||||
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName()
|
||||
+ ".uriTemplate";
|
||||
|
||||
private ClientRequest request;
|
||||
|
||||
|
|
@ -49,8 +50,10 @@ public class WebClientExchangeTagsTests {
|
|||
@Before
|
||||
public void setup() {
|
||||
this.request = ClientRequest
|
||||
.create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot"))
|
||||
.attribute(URI_TEMPLATE_ATTRIBUTE, "http://example.org/projects/{project}")
|
||||
.create(HttpMethod.GET,
|
||||
URI.create("http://example.org/projects/spring-boot"))
|
||||
.attribute(URI_TEMPLATE_ATTRIBUTE,
|
||||
"http://example.org/projects/{project}")
|
||||
.build();
|
||||
this.response = mock(ClientResponse.class);
|
||||
given(this.response.statusCode()).willReturn(HttpStatus.OK);
|
||||
|
|
@ -71,18 +74,17 @@ public class WebClientExchangeTagsTests {
|
|||
@Test
|
||||
public void uriWhenRelativeTemplateIsAvailableShouldReturnTemplate() {
|
||||
this.request = ClientRequest
|
||||
.create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot"))
|
||||
.attribute(URI_TEMPLATE_ATTRIBUTE, "/projects/{project}")
|
||||
.build();
|
||||
.create(HttpMethod.GET,
|
||||
URI.create("http://example.org/projects/spring-boot"))
|
||||
.attribute(URI_TEMPLATE_ATTRIBUTE, "/projects/{project}").build();
|
||||
assertThat(WebClientExchangeTags.uri(this.request))
|
||||
.isEqualTo(Tag.of("uri", "/projects/{project}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uriWhenTemplateIsMissingShouldReturnPath() {
|
||||
this.request = ClientRequest
|
||||
.create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot"))
|
||||
.build();
|
||||
this.request = ClientRequest.create(HttpMethod.GET,
|
||||
URI.create("http://example.org/projects/spring-boot")).build();
|
||||
assertThat(WebClientExchangeTags.uri(this.request))
|
||||
.isEqualTo(Tag.of("uri", "/projects/spring-boot"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ public class CouchbaseConfiguration {
|
|||
@Bean
|
||||
@Primary
|
||||
public Cluster couchbaseCluster() {
|
||||
return CouchbaseCluster.create(couchbaseEnvironment(),
|
||||
determineBootstrapHosts());
|
||||
return CouchbaseCluster.create(couchbaseEnvironment(), determineBootstrapHosts());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -75,10 +74,8 @@ public class CouchbaseConfiguration {
|
|||
@Primary
|
||||
@DependsOn("couchbaseClient")
|
||||
public ClusterInfo couchbaseClusterInfo() {
|
||||
return couchbaseCluster()
|
||||
.clusterManager(this.properties.getBucket().getName(),
|
||||
this.properties.getBucket().getPassword())
|
||||
.info();
|
||||
return couchbaseCluster().clusterManager(this.properties.getBucket().getName(),
|
||||
this.properties.getBucket().getPassword()).info();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -113,8 +110,8 @@ public class CouchbaseConfiguration {
|
|||
builder = builder.viewServiceConfig(getViewServiceConfig(endpoints));
|
||||
}
|
||||
if (timeouts.getSocketConnect() != null) {
|
||||
builder = builder.socketConnectTimeout(
|
||||
(int) timeouts.getSocketConnect().toMillis());
|
||||
builder = builder
|
||||
.socketConnectTimeout((int) timeouts.getSocketConnect().toMillis());
|
||||
}
|
||||
if (timeouts.getView() != null) {
|
||||
builder = builder.viewTimeout(timeouts.getView().toMillis());
|
||||
|
|
@ -147,8 +144,7 @@ public class CouchbaseConfiguration {
|
|||
private <T> T getServiceConfig(CouchbaseService service, Integer fallback,
|
||||
BiFunction<Integer, Integer, T> factory) {
|
||||
if (service.getMinEndpoints() != 1 || service.getMaxEndpoints() != 1) {
|
||||
return factory.apply(service.getMinEndpoints(),
|
||||
service.getMaxEndpoints());
|
||||
return factory.apply(service.getMinEndpoints(), service.getMaxEndpoints());
|
||||
}
|
||||
int endpoints = (fallback != null ? fallback : 1);
|
||||
return factory.apply(endpoints, endpoints);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
|
|||
|
|
@ -578,6 +578,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
|||
}
|
||||
return String.format("-D%s=\"%s\"", key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ public class RunMojo extends AbstractRunMojo {
|
|||
|
||||
@Override
|
||||
protected void runWithForkedJvm(File workingDirectory, List<String> args,
|
||||
Map<String, String> environmentVariables)
|
||||
throws MojoExecutionException {
|
||||
Map<String, String> environmentVariables) throws MojoExecutionException {
|
||||
try {
|
||||
RunProcess runProcess = new RunProcess(workingDirectory,
|
||||
new JavaExecutable().toString());
|
||||
|
|
|
|||
|
|
@ -103,8 +103,7 @@ public class StartMojo extends AbstractRunMojo {
|
|||
}
|
||||
|
||||
private RunProcess runProcess(File workingDirectory, List<String> args,
|
||||
Map<String, String> environmentVariables)
|
||||
throws MojoExecutionException {
|
||||
Map<String, String> environmentVariables) throws MojoExecutionException {
|
||||
try {
|
||||
RunProcess runProcess = new RunProcess(workingDirectory,
|
||||
new JavaExecutable().toString());
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class EnvVariablesTests {
|
|||
|
||||
@Test
|
||||
public void asArray() {
|
||||
assertThat(new EnvVariables(getTestArgs()).asArray())
|
||||
.contains("key=My Value", "key1= tt ", "key2= ", "key3=");
|
||||
assertThat(new EnvVariables(getTestArgs()).asArray()).contains("key=My Value",
|
||||
"key1= tt ", "key2= ", "key3=");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue