Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
7b120c1c
Commit
7b120c1c
authored
May 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
42c053cf
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
212 additions
and
206 deletions
+212
-206
OnEnabledEndpointCondition.java
...figure/endpoint/condition/OnEnabledEndpointCondition.java
+3
-4
IntegrationGraphEndpointAutoConfiguration.java
...ntegration/IntegrationGraphEndpointAutoConfiguration.java
+2
-2
WebClientMetricsAutoConfiguration.java
...trics/web/reactive/WebClientMetricsAutoConfiguration.java
+10
-9
WebFluxMetricsAutoConfiguration.java
...metrics/web/reactive/WebFluxMetricsAutoConfiguration.java
+2
-2
CachesEndpointAutoConfigurationTests.java
...configure/cache/CachesEndpointAutoConfigurationTests.java
+4
-5
ConditionalOnEnabledEndpointTests.java
...endpoint/condition/ConditionalOnEnabledEndpointTests.java
+16
-15
CachesEndpointDocumentationTests.java
...t/web/documentation/CachesEndpointDocumentationTests.java
+19
-19
IntegrationGraphEndpointDocumentationTests.java
...mentation/IntegrationGraphEndpointDocumentationTests.java
+4
-3
IntegrationGraphEndpointAutoConfigurationTests.java
...ation/IntegrationGraphEndpointAutoConfigurationTests.java
+2
-2
HibernateMetricsAutoConfigurationTests.java
...trics/orm/jpa/HibernateMetricsAutoConfigurationTests.java
+4
-3
RestTemplateMetricsAutoConfigurationTests.java
...web/client/RestTemplateMetricsAutoConfigurationTests.java
+21
-19
WebClientMetricsAutoConfigurationTests.java
.../web/reactive/WebClientMetricsAutoConfigurationTests.java
+1
-0
WebFluxMetricsAutoConfigurationTests.java
...cs/web/reactive/WebFluxMetricsAutoConfigurationTests.java
+2
-0
CachesEndpoint.java
...rg/springframework/boot/actuate/cache/CachesEndpoint.java
+16
-18
DefaultWebClientExchangeTagsProvider.java
...reactive/client/DefaultWebClientExchangeTagsProvider.java
+1
-0
MetricsWebClientFilterFunction.java
...s/web/reactive/client/MetricsWebClientFilterFunction.java
+3
-4
WebClientExchangeTags.java
...te/metrics/web/reactive/client/WebClientExchangeTags.java
+9
-8
WebClientExchangeTagsProvider.java
...cs/web/reactive/client/WebClientExchangeTagsProvider.java
+3
-1
package-info.java
...oot/actuate/metrics/web/reactive/client/package-info.java
+2
-2
CachesEndpointTests.java
...ringframework/boot/actuate/cache/CachesEndpointTests.java
+18
-18
CachesEndpointWebIntegrationTests.java
...boot/actuate/cache/CachesEndpointWebIntegrationTests.java
+15
-18
IntegrationGraphEndpointWebIntegrationTests.java
...egration/IntegrationGraphEndpointWebIntegrationTests.java
+8
-6
DefaultWebClientExchangeTagsProviderTests.java
...ive/client/DefaultWebClientExchangeTagsProviderTests.java
+23
-22
MetricsWebClientCustomizerTests.java
.../web/reactive/client/MetricsWebClientCustomizerTests.java
+1
-0
WebClientExchangeTagsTests.java
...trics/web/reactive/client/WebClientExchangeTagsTests.java
+11
-9
CouchbaseConfiguration.java
.../boot/autoconfigure/couchbase/CouchbaseConfiguration.java
+6
-10
DispatcherServletAutoConfiguration.java
...igure/web/servlet/DispatcherServletAutoConfiguration.java
+1
-1
AbstractRunMojo.java
.../java/org/springframework/boot/maven/AbstractRunMojo.java
+1
-0
RunMojo.java
...src/main/java/org/springframework/boot/maven/RunMojo.java
+1
-2
StartMojo.java
...c/main/java/org/springframework/boot/maven/StartMojo.java
+1
-2
EnvVariablesTests.java
...ava/org/springframework/boot/maven/EnvVariablesTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnEnabledEndpointCondition.java
View file @
7b120c1c
...
...
@@ -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
)
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfiguration.java
View file @
7b120c1c
...
...
@@ -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 {
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java
View file @
7b120c1c
...
...
@@ -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
());
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java
View file @
7b120c1c
...
...
@@ -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
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfigurationTests.java
View file @
7b120c1c
...
...
@@ -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
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java
View file @
7b120c1c
...
...
@@ -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
)
->
{
this
.
contextRunner
.
withUserConfiguration
(
ComponentWithNoEndpointReferenceConfiguration
.
class
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
assertThat
(
context
.
getStartupFailure
().
getCause
().
getMessage
()).
contains
(
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
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java
View file @
7b120c1c
...
...
@@ -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,11 +68,10 @@ 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
(
fieldWithPath
(
"cacheManagers.*"
).
description
(
"Caches in the application context keyed by "
+
"name."
))
.
andWithPrefix
(
"cacheManagers.*.*."
,
fieldWithPath
(
"target"
).
description
(
"Fully qualified name of the native cache."
))));
}
...
...
@@ -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
);
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/IntegrationGraphEndpointDocumentationTests.java
View file @
7b120c1c
...
...
@@ -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"
));
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfigurationTests.java
View file @
7b120c1c
...
...
@@ -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
);
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
...
@@ -90,7 +90,8 @@ public class HibernateMetricsAutoConfigurationTests {
@Test
public
void
entityManagerFactoryInstrumentationCanBeDisabled
()
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.enable.hibernate=false"
,
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.enable.hibernate=false"
,
"spring.jpa.properties.hibernate.generate_statistics:true"
)
.
run
((
context
)
->
{
context
.
getBean
(
EntityManagerFactory
.
class
)
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
...
@@ -78,7 +78,8 @@ public class RestTemplateMetricsAutoConfigurationTests {
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=10"
)
.
run
((
context
)
->
{
MetricsProperties
properties
=
context
.
getBean
(
MetricsProperties
.
class
);
MetricsProperties
properties
=
context
.
getBean
(
MetricsProperties
.
class
);
int
maxUriTags
=
properties
.
getWeb
().
getClient
().
getMaxUriTags
();
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
RestTemplate
restTemplate
=
context
.
getBean
(
RestTemplateBuilder
.
class
)
...
...
@@ -92,7 +93,8 @@ public class RestTemplateMetricsAutoConfigurationTests {
for
(
int
i
=
0
;
i
<
maxUriTags
+
10
;
i
++)
{
restTemplate
.
getForObject
(
"/test/"
+
i
,
String
.
class
);
}
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
()).
hasSize
(
maxUriTags
);
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'"
);
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
...
@@ -116,6 +116,7 @@ public class WebClientMetricsAutoConfigurationTests {
public
WebClientExchangeTagsProvider
customTagProvider
()
{
return
mock
(
WebClientExchangeTagsProvider
.
class
);
}
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java
View file @
7b120c1c
...
...
@@ -65,5 +65,7 @@ public class WebFluxMetricsAutoConfigurationTests {
public
WebFluxTagsProvider
customWebFluxTagsProvider
()
{
return
mock
(
WebFluxTagsProvider
.
class
);
}
}
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java
View file @
7b120c1c
...
...
@@ -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,16 +121,14 @@ 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
()
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
{
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java
View file @
7b120c1c
...
...
@@ -47,4 +47,5 @@ public class DefaultWebClientExchangeTagsProvider
WebClientExchangeTags
.
status
(
throwable
));
}
}
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java
View file @
7b120c1c
...
...
@@ -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
);
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java
View file @
7b120c1c
...
...
@@ -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
*/
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java
View file @
7b120c1c
...
...
@@ -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
);
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/package-info.java
View file @
7b120c1c
...
...
@@ -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
;
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java
View file @
7b120c1c
...
...
@@ -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
();
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointWebIntegrationTests.java
View file @
7b120c1c
...
...
@@ -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
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointWebIntegrationTests.java
View file @
7b120c1c
...
...
@@ -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
)
.
ex
change
().
ex
pectStatus
().
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
)
.
ex
change
().
ex
pectStatus
().
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
);
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java
View file @
7b120c1c
...
...
@@ -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
,
n
ull
,
n
ew
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
,
n
ull
,
n
ew
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"
));
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientCustomizerTests.java
View file @
7b120c1c
...
...
@@ -60,4 +60,5 @@ public class MetricsWebClientCustomizerTests {
this
.
clientBuilder
.
filters
((
filters
)
->
assertThat
(
filters
).
hasSize
(
1
).
first
()
.
isInstanceOf
(
MetricsWebClientFilterFunction
.
class
));
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java
View file @
7b120c1c
...
...
@@ -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"
));
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java
View file @
7b120c1c
...
...
@@ -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
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java
View file @
7b120c1c
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java
View file @
7b120c1c
...
...
@@ -578,6 +578,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
return
String
.
format
(
"-D%s=\"%s\""
,
key
,
value
);
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java
View file @
7b120c1c
...
...
@@ -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
());
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java
View file @
7b120c1c
...
...
@@ -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
());
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/EnvVariablesTests.java
View file @
7b120c1c
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment