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
3702da45
Commit
3702da45
authored
May 26, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
22157091
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
195 additions
and
199 deletions
+195
-199
CompositeReactiveHealthIndicatorConfiguration.java
...health/CompositeReactiveHealthIndicatorConfiguration.java
+2
-2
HealthIndicatorAutoConfiguration.java
...utoconfigure/health/HealthIndicatorAutoConfiguration.java
+5
-3
PropertiesMeterFilter.java
.../actuate/autoconfigure/metrics/PropertiesMeterFilter.java
+5
-3
CloudFoundryWebEndpointDiscovererTests.java
.../cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java
+2
-2
HealthEndpointDocumentationTests.java
...t/web/documentation/HealthEndpointDocumentationTests.java
+6
-8
HealthEndpointWebExtensionTests.java
...autoconfigure/health/HealthEndpointWebExtensionTests.java
+59
-64
ReactiveHealthEndpointWebExtensionTests.java
...igure/health/ReactiveHealthEndpointWebExtensionTests.java
+3
-4
MetricsAutoConfigurationIntegrationTests.java
...ure/metrics/MetricsAutoConfigurationIntegrationTests.java
+2
-3
CachesEndpoint.java
...rg/springframework/boot/actuate/cache/CachesEndpoint.java
+2
-2
CompositeHealthIndicator.java
...amework/boot/actuate/health/CompositeHealthIndicator.java
+8
-10
CompositeHealthIndicatorFactory.java
.../boot/actuate/health/CompositeHealthIndicatorFactory.java
+2
-2
CompositeReactiveHealthIndicator.java
...boot/actuate/health/CompositeReactiveHealthIndicator.java
+2
-2
DefaultHealthIndicatorRegistry.java
...k/boot/actuate/health/DefaultHealthIndicatorRegistry.java
+3
-4
DefaultReactiveHealthIndicatorRegistry.java
...ctuate/health/DefaultReactiveHealthIndicatorRegistry.java
+2
-2
HealthEndpointWebExtension.java
...ework/boot/actuate/health/HealthEndpointWebExtension.java
+2
-2
HealthIndicatorRegistry.java
...ramework/boot/actuate/health/HealthIndicatorRegistry.java
+12
-13
HealthIndicatorRegistryFactory.java
...k/boot/actuate/health/HealthIndicatorRegistryFactory.java
+2
-4
ReactiveHealthIndicatorRegistry.java
.../boot/actuate/health/ReactiveHealthIndicatorRegistry.java
+10
-11
CompositeReactiveHealthIndicatorTests.java
...actuate/health/CompositeReactiveHealthIndicatorTests.java
+11
-11
DefaultReactiveHealthIndicatorRegistryTests.java
...e/health/DefaultReactiveHealthIndicatorRegistryTests.java
+4
-4
HealthEndpointTests.java
...ingframework/boot/actuate/health/HealthEndpointTests.java
+6
-6
HealthEndpointWebIntegrationTests.java
...oot/actuate/health/HealthEndpointWebIntegrationTests.java
+7
-6
HealthWebEndpointResponseMapperTests.java
.../actuate/health/HealthWebEndpointResponseMapperTests.java
+12
-9
ReactiveHealthIndicatorRegistryFactoryTests.java
...e/health/ReactiveHealthIndicatorRegistryFactoryTests.java
+7
-5
RestClientBuilderCustomizer.java
...igure/elasticsearch/rest/RestClientBuilderCustomizer.java
+1
-0
RestClientProperties.java
...utoconfigure/elasticsearch/rest/RestClientProperties.java
+1
-2
JestAutoConfigurationTests.java
...figure/elasticsearch/jest/JestAutoConfigurationTests.java
+6
-5
RestClientAutoConfigurationTests.java
.../elasticsearch/rest/RestClientAutoConfigurationTests.java
+2
-0
LiquibaseAutoConfigurationTests.java
...oconfigure/liquibase/LiquibaseAutoConfigurationTests.java
+1
-3
WebMvcTestPageableIntegrationTests.java
...b/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java
+1
-2
AbstractRunMojo.java
.../java/org/springframework/boot/maven/AbstractRunMojo.java
+4
-2
RepackageMojo.java
...in/java/org/springframework/boot/maven/RepackageMojo.java
+3
-3
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthIndicatorConfiguration.java
View file @
3702da45
...
...
@@ -44,8 +44,8 @@ public abstract class CompositeReactiveHealthIndicatorConfiguration<H extends Re
return
createHealthIndicator
(
beans
.
values
().
iterator
().
next
());
}
ReactiveHealthIndicatorRegistry
registry
=
new
DefaultReactiveHealthIndicatorRegistry
();
beans
.
forEach
(
(
name
,
source
)
->
registry
.
register
(
name
,
createHealthIndicator
(
source
)));
beans
.
forEach
(
(
name
,
source
)
->
registry
.
register
(
name
,
createHealthIndicator
(
source
)));
return
new
CompositeReactiveHealthIndicator
(
this
.
healthAggregator
,
registry
);
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java
View file @
3702da45
...
...
@@ -89,9 +89,11 @@ public class HealthIndicatorAutoConfiguration {
public
ReactiveHealthIndicatorRegistry
reactiveHealthIndicatorRegistry
(
ObjectProvider
<
Map
<
String
,
ReactiveHealthIndicator
>>
reactiveHealthIndicators
,
ObjectProvider
<
Map
<
String
,
HealthIndicator
>>
healthIndicators
)
{
return
new
ReactiveHealthIndicatorRegistryFactory
().
createReactiveHealthIndicatorRegistry
(
reactiveHealthIndicators
.
getIfAvailable
(
Collections:
:
emptyMap
),
healthIndicators
.
getIfAvailable
(
Collections:
:
emptyMap
));
return
new
ReactiveHealthIndicatorRegistryFactory
()
.
createReactiveHealthIndicatorRegistry
(
reactiveHealthIndicators
.
getIfAvailable
(
Collections:
:
emptyMap
),
healthIndicators
.
getIfAvailable
(
Collections:
:
emptyMap
));
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java
View file @
3702da45
...
...
@@ -57,10 +57,12 @@ public class PropertiesMeterFilter implements MeterFilter {
private
static
MeterFilter
createMapFilter
(
Map
<
String
,
String
>
tags
)
{
if
(
tags
.
isEmpty
())
{
return
new
MeterFilter
()
{
};
return
new
MeterFilter
()
{
};
}
Tags
commonTags
=
Tags
.
of
(
tags
.
entrySet
().
stream
().
map
((
entry
)
->
Tag
.
of
(
entry
.
getKey
(),
entry
.
getValue
())).
collect
(
Collectors
.
toList
()));
Tags
commonTags
=
Tags
.
of
(
tags
.
entrySet
().
stream
()
.
map
((
entry
)
->
Tag
.
of
(
entry
.
getKey
(),
entry
.
getValue
()))
.
collect
(
Collectors
.
toList
()));
return
MeterFilter
.
commonTags
(
commonTags
);
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java
View file @
3702da45
...
...
@@ -73,8 +73,8 @@ public class CloudFoundryWebEndpointDiscovererTests {
return
operation
;
}
}
throw
new
IllegalStateException
(
"No main read operation found from "
+
endpoint
.
getOperations
());
throw
new
IllegalStateException
(
"No main read operation found from "
+
endpoint
.
getOperations
());
}
private
void
load
(
Class
<?>
configuration
,
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java
View file @
3702da45
...
...
@@ -61,8 +61,7 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati
fieldWithPath
(
"status"
)
.
description
(
"Status of a specific part of the application"
),
subsectionWithPath
(
"details"
).
description
(
"Details of the health of a specific part of the"
+
" application."
));
"Details of the health of a specific part of the"
+
" application."
));
@Test
public
void
health
()
throws
Exception
{
...
...
@@ -111,18 +110,17 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati
}
@Bean
public
DataSourceHealthIndicator
dbHealthIndicator
(
DataSource
dataSource
)
{
public
DataSourceHealthIndicator
dbHealthIndicator
(
DataSource
dataSource
)
{
return
new
DataSourceHealthIndicator
(
dataSource
);
}
@Bean
public
CompositeHealthIndicator
brokerHealthIndicator
()
{
Map
<
String
,
HealthIndicator
>
indicators
=
new
LinkedHashMap
<>();
indicators
.
put
(
"us1"
,
()
->
Health
.
up
().
withDetail
(
"version"
,
"1.0.2"
)
.
build
());
indicators
.
put
(
"us2"
,
()
->
Health
.
up
().
withDetail
(
"version"
,
"1.0.4"
)
.
build
());
indicators
.
put
(
"us1"
,
()
->
Health
.
up
().
withDetail
(
"version"
,
"1.0.2"
)
.
build
());
indicators
.
put
(
"us2"
,
()
->
Health
.
up
().
withDetail
(
"version"
,
"1.0.4"
)
.
build
());
return
new
CompositeHealthIndicator
(
new
OrderedHealthAggregator
(),
new
DefaultHealthIndicatorRegistry
(
indicators
));
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java
View file @
3702da45
...
...
@@ -53,8 +53,7 @@ import static org.mockito.Mockito.mock;
public
class
HealthEndpointWebExtensionTests
{
private
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
.
withUserConfiguration
(
HealthIndicatorsConfiguration
.
class
)
.
withConfiguration
(
.
withUserConfiguration
(
HealthIndicatorsConfiguration
.
class
).
withConfiguration
(
AutoConfigurations
.
of
(
HealthIndicatorAutoConfiguration
.
class
,
HealthEndpointAutoConfiguration
.
class
));
...
...
@@ -96,8 +95,9 @@ public class HealthEndpointWebExtensionTests {
this
.
contextRunner
.
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
assertThat
(
extension
.
health
(
mock
(
SecurityContext
.
class
)).
getBody
()
.
getDetails
()).
isEmpty
();
assertThat
(
extension
.
health
(
mock
(
SecurityContext
.
class
)).
getBody
().
getDetails
())
.
isEmpty
();
});
}
...
...
@@ -124,9 +124,8 @@ public class HealthEndpointWebExtensionTests {
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isNotEmpty
();
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isNotEmpty
();
});
}
...
...
@@ -165,9 +164,8 @@ public class HealthEndpointWebExtensionTests {
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isEmpty
();
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isEmpty
();
});
}
...
...
@@ -182,9 +180,8 @@ public class HealthEndpointWebExtensionTests {
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isNotEmpty
();
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isNotEmpty
();
});
}
...
...
@@ -193,8 +190,8 @@ public class HealthEndpointWebExtensionTests {
this
.
contextRunner
.
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
assertDetailsNotFound
(
extension
.
healthForComponent
(
mock
(
SecurityContext
.
class
),
"simple"
));
assertDetailsNotFound
(
extension
.
healthForComponent
(
mock
(
SecurityContext
.
class
),
"simple"
));
});
}
...
...
@@ -205,8 +202,8 @@ public class HealthEndpointWebExtensionTests {
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
()).
willReturn
(
mock
(
Principal
.
class
));
assertDetailsNotFound
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
assertDetailsNotFound
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
});
}
...
...
@@ -221,8 +218,8 @@ public class HealthEndpointWebExtensionTests {
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
assertSimpleComponent
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
assertSimpleComponent
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
});
}
...
...
@@ -244,8 +241,8 @@ public class HealthEndpointWebExtensionTests {
.
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
assertDetailsNotFound
(
extension
.
healthForComponent
(
mock
(
SecurityContext
.
class
),
"simple"
));
assertDetailsNotFound
(
extension
.
healthForComponent
(
mock
(
SecurityContext
.
class
),
"simple"
));
});
}
...
...
@@ -254,15 +251,15 @@ public class HealthEndpointWebExtensionTests {
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.health.show-details=when-authorized"
,
"management.endpoint.health.roles=ACTUATOR"
).
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
assertDetailsNotFound
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
});
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
assertDetailsNotFound
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
});
}
@Test
...
...
@@ -270,15 +267,15 @@ public class HealthEndpointWebExtensionTests {
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.health.show-details=when-authorized"
,
"management.endpoint.health.roles=ACTUATOR"
).
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
assertSimpleComponent
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
});
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
assertSimpleComponent
(
extension
.
healthForComponent
(
securityContext
,
"simple"
));
});
}
@Test
...
...
@@ -288,8 +285,8 @@ public class HealthEndpointWebExtensionTests {
.
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
assertDetailsNotFound
(
extension
.
healthForComponent
(
null
,
"does-not-exist"
));
assertDetailsNotFound
(
extension
.
healthForComponent
(
null
,
"does-not-exist"
));
});
}
...
...
@@ -360,15 +357,15 @@ public class HealthEndpointWebExtensionTests {
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.health.show-details=when-authorized"
,
"management.endpoint.health.roles=ACTUATOR"
).
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
assertDetailsNotFound
(
extension
.
healthForComponentInstance
(
securityContext
,
"composite"
,
"one"
));
});
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
assertDetailsNotFound
(
extension
.
healthForComponentInstance
(
securityContext
,
"composite"
,
"one"
));
});
}
@Test
...
...
@@ -376,15 +373,15 @@ public class HealthEndpointWebExtensionTests {
this
.
contextRunner
.
withPropertyValues
(
"management.endpoint.health.show-details=when-authorized"
,
"management.endpoint.health.roles=ACTUATOR"
).
run
((
context
)
->
{
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
assertSimpleComponent
(
extension
.
healthForComponentInstance
(
securityContext
,
"composite"
,
"one"
));
});
HealthEndpointWebExtension
extension
=
context
.
getBean
(
HealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
assertSimpleComponent
(
extension
.
healthForComponentInstance
(
securityContext
,
"composite"
,
"one"
));
});
}
@Test
...
...
@@ -406,8 +403,7 @@ public class HealthEndpointWebExtensionTests {
private
void
assertSimpleComponent
(
WebEndpointResponse
<
Health
>
response
)
{
assertThat
(
response
.
getStatus
()).
isEqualTo
(
HttpStatus
.
OK
.
value
());
assertThat
(
response
.
getBody
().
getDetails
()).
containsOnly
(
entry
(
"counter"
,
42
));
assertThat
(
response
.
getBody
().
getDetails
()).
containsOnly
(
entry
(
"counter"
,
42
));
}
@Test
...
...
@@ -421,9 +417,8 @@ public class HealthEndpointWebExtensionTests {
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ADMIN"
)).
willReturn
(
true
);
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isNotEmpty
();
assertThat
(
extension
.
health
(
securityContext
).
getBody
().
getDetails
())
.
isNotEmpty
();
});
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointWebExtensionTests.java
View file @
3702da45
...
...
@@ -220,12 +220,11 @@ public class ReactiveHealthEndpointWebExtensionTests {
@Test
public
void
registryCanBeAltered
()
{
this
.
contextRunner
.
withUserConfiguration
(
HealthIndicatorsConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
HealthIndicatorsConfiguration
.
class
)
.
withPropertyValues
(
"management.endpoint.health.show-details=always"
)
.
run
((
context
)
->
{
ReactiveHealthIndicatorRegistry
registry
=
context
.
getBean
(
ReactiveHealthIndicatorRegistry
.
class
);
ReactiveHealthIndicatorRegistry
registry
=
context
.
getBean
(
ReactiveHealthIndicatorRegistry
.
class
);
ReactiveHealthEndpointWebExtension
extension
=
context
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
assertThat
(
extension
.
health
(
null
).
block
().
getBody
().
getDetails
())
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationIntegrationTests.java
View file @
3702da45
...
...
@@ -58,13 +58,12 @@ public class MetricsAutoConfigurationIntegrationTests {
@Test
public
void
propertyBasedCommonTagsIsAutoConfigured
()
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.tags.region=test"
,
"management.metrics.tags.origin=local"
)
.
run
((
context
)
->
{
"management.metrics.tags.origin=local"
).
run
((
context
)
->
{
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
registry
.
counter
(
"my.counter"
,
"env"
,
"qa"
);
assertThat
(
registry
.
find
(
"my.counter"
).
tags
(
"env"
,
"qa"
)
.
tags
(
"region"
,
"test"
).
tags
(
"origin"
,
"local"
).
counter
())
.
isNotNull
();
.
isNotNull
();
});
}
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java
View file @
3702da45
...
...
@@ -68,8 +68,8 @@ public class CachesEndpoint {
new
CacheDescriptor
(
entry
.
getTarget
()));
});
Map
<
String
,
CacheManagerDescriptor
>
cacheManagerDescriptors
=
new
LinkedHashMap
<>();
descriptors
.
forEach
((
name
,
entries
)
->
cacheManagerDescriptors
.
put
(
name
,
new
CacheManagerDescriptor
(
entries
)));
descriptors
.
forEach
((
name
,
entries
)
->
cacheManagerDescriptors
.
put
(
name
,
new
CacheManagerDescriptor
(
entries
)));
return
new
CachesReport
(
cacheManagerDescriptors
);
}
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java
View file @
3702da45
...
...
@@ -45,11 +45,10 @@ public class CompositeHealthIndicator implements HealthIndicator {
}
/**
* Create a new {@link CompositeHealthIndicator} from the specified
* indicators.
* Create a new {@link CompositeHealthIndicator} from the specified indicators.
* @param healthAggregator the health aggregator
* @param indicators a map of {@link HealthIndicator HealthIndicators} with
*
the key
being used as an indicator name.
* @param indicators a map of {@link HealthIndicator HealthIndicators} with
the key
* being used as an indicator name.
* @deprecated since 2.1.0 in favour of
* {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)}
*/
...
...
@@ -60,8 +59,8 @@ public class CompositeHealthIndicator implements HealthIndicator {
}
/**
* Create a new {@link CompositeHealthIndicator} from the indicators in the
*
given
{@code registry}.
* Create a new {@link CompositeHealthIndicator} from the indicators in the
given
* {@code registry}.
* @param healthAggregator the health aggregator
* @param registry the registry of {@link HealthIndicator HealthIndicators}.
*/
...
...
@@ -72,12 +71,11 @@ public class CompositeHealthIndicator implements HealthIndicator {
}
/**
* Adds the given {@code healthIndicator}, associating it with the given
* {@code name}.
* Adds the given {@code healthIndicator}, associating it with the given {@code name}.
* @param name the name of the indicator
* @param indicator the indicator
* @throws IllegalStateException if an indicator with the given {@code name}
*
is
already registered.
* @throws IllegalStateException if an indicator with the given {@code name}
is
* already registered.
* @deprecated since 2.1.0 in favour of
* {@link HealthIndicatorRegistry#register(String, HealthIndicator)}
*/
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorFactory.java
View file @
3702da45
...
...
@@ -57,8 +57,8 @@ public class CompositeHealthIndicatorFactory {
Assert
.
notNull
(
healthIndicators
,
"HealthIndicators must not be null"
);
HealthIndicatorRegistryFactory
factory
=
new
HealthIndicatorRegistryFactory
(
this
.
healthIndicatorNameFactory
);
return
new
CompositeHealthIndicator
(
healthAggregator
,
factory
.
createHealthIndicatorRegistry
(
healthIndicators
));
return
new
CompositeHealthIndicator
(
healthAggregator
,
factory
.
createHealthIndicatorRegistry
(
healthIndicators
));
}
}
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java
View file @
3702da45
...
...
@@ -91,8 +91,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator
* @param name the name of the health indicator
* @param indicator the health indicator to add
* @return this instance
* @throws IllegalStateException if an indicator with the given {@code name}
*
is
already registered.
* @throws IllegalStateException if an indicator with the given {@code name}
is
* already registered.
* @deprecated since 2.1.0 in favour of
* {@link ReactiveHealthIndicatorRegistry#register(String, ReactiveHealthIndicator)}
*/
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultHealthIndicatorRegistry.java
View file @
3702da45
...
...
@@ -43,10 +43,9 @@ public class DefaultHealthIndicatorRegistry implements HealthIndicatorRegistry {
}
/**
* Create a new {@link DefaultHealthIndicatorRegistry} from the specified
* indicators.
* @param healthIndicators a map of {@link HealthIndicator}s with the key
* being used as an indicator name.
* Create a new {@link DefaultHealthIndicatorRegistry} from the specified indicators.
* @param healthIndicators a map of {@link HealthIndicator}s with the key being used
* as an indicator name.
*/
public
DefaultHealthIndicatorRegistry
(
Map
<
String
,
HealthIndicator
>
healthIndicators
)
{
Assert
.
notNull
(
healthIndicators
,
"HealthIndicators must not be null"
);
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistry.java
View file @
3702da45
...
...
@@ -46,8 +46,8 @@ public class DefaultReactiveHealthIndicatorRegistry
/**
* Create a new {@link DefaultReactiveHealthIndicatorRegistry} from the specified
* indicators.
* @param healthIndicators a map of {@link HealthIndicator}s with the key
*
being used
as an indicator name.
* @param healthIndicators a map of {@link HealthIndicator}s with the key
being used
* as an indicator name.
*/
public
DefaultReactiveHealthIndicatorRegistry
(
Map
<
String
,
ReactiveHealthIndicator
>
healthIndicators
)
{
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java
View file @
3702da45
...
...
@@ -65,8 +65,8 @@ public class HealthEndpointWebExtension {
public
WebEndpointResponse
<
Health
>
healthForComponentInstance
(
SecurityContext
securityContext
,
@Selector
String
component
,
@Selector
String
instance
)
{
Supplier
<
Health
>
health
=
()
->
this
.
delegate
.
healthForComponentInstance
(
component
,
instance
);
Supplier
<
Health
>
health
=
()
->
this
.
delegate
.
healthForComponentInstance
(
component
,
instance
);
return
this
.
responseMapper
.
mapDetails
(
health
,
securityContext
);
}
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistry.java
View file @
3702da45
...
...
@@ -31,36 +31,35 @@ import java.util.Map;
public
interface
HealthIndicatorRegistry
{
/**
* Registers the given {@link HealthIndicator}, associating it with the
*
given
{@code name}.
* Registers the given {@link HealthIndicator}, associating it with the
given
* {@code name}.
* @param name the name of the indicator
* @param healthIndicator the indicator
* @throws IllegalStateException if an indicator with the given {@code name}
*
is
already registered.
* @throws IllegalStateException if an indicator with the given {@code name}
is
* already registered.
*/
void
register
(
String
name
,
HealthIndicator
healthIndicator
);
/**
* Unregisters the {@link HealthIndicator} previously registered with the
*
given
{@code name}.
* Unregisters the {@link HealthIndicator} previously registered with the
given
* {@code name}.
* @param name the name of the indicator
* @return the unregistered indicator, or {@code null} if no indicator was
*
found in
the registry for the given {@code name}.
* @return the unregistered indicator, or {@code null} if no indicator was
found in
* the registry for the given {@code name}.
*/
HealthIndicator
unregister
(
String
name
);
/**
* Returns the {@link HealthIndicator} registered with the given {@code name}.
* @param name the name of the indicator
* @return the health indicator, or {@code null} if no indicator was
*
registered with
the given {@code name}.
* @return the health indicator, or {@code null} if no indicator was
registered with
* the given {@code name}.
*/
HealthIndicator
get
(
String
name
);
/**
* Returns a snapshot of the registered health indicators and their names.
* The contents of the map do not reflect subsequent changes to the
* registry.
* Returns a snapshot of the registered health indicators and their names. The
* contents of the map do not reflect subsequent changes to the registry.
* @return the snapshot of registered health indicators
*/
Map
<
String
,
HealthIndicator
>
getAll
();
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistryFactory.java
View file @
3702da45
...
...
@@ -41,10 +41,8 @@ public class HealthIndicatorRegistryFactory {
}
/**
* Create a {@link HealthIndicatorRegistry} based on the specified health
* indicators.
* @param healthIndicators the {@link HealthIndicator} instances mapped by
* name
* Create a {@link HealthIndicatorRegistry} based on the specified health indicators.
* @param healthIndicators the {@link HealthIndicator} instances mapped by name
* @return a {@link HealthIndicator} that delegates to the specified
* {@code healthIndicators}.
*/
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistry.java
View file @
3702da45
...
...
@@ -31,12 +31,12 @@ import java.util.Map;
public
interface
ReactiveHealthIndicatorRegistry
{
/**
* Registers the given {@link ReactiveHealthIndicator}, associating it with the
*
given
{@code name}.
* Registers the given {@link ReactiveHealthIndicator}, associating it with the
given
* {@code name}.
* @param name the name of the indicator
* @param healthIndicator the indicator
* @throws IllegalStateException if an indicator with the given {@code name}
*
is
already registered.
* @throws IllegalStateException if an indicator with the given {@code name}
is
* already registered.
*/
void
register
(
String
name
,
ReactiveHealthIndicator
healthIndicator
);
...
...
@@ -44,23 +44,22 @@ public interface ReactiveHealthIndicatorRegistry {
* Unregisters the {@link ReactiveHealthIndicator} previously registered with the
* given {@code name}.
* @param name the name of the indicator
* @return the unregistered indicator, or {@code null} if no indicator was
*
found in
the registry for the given {@code name}.
* @return the unregistered indicator, or {@code null} if no indicator was
found in
* the registry for the given {@code name}.
*/
ReactiveHealthIndicator
unregister
(
String
name
);
/**
* Returns the {@link ReactiveHealthIndicator} registered with the given {@code name}.
* @param name the name of the indicator
* @return the health indicator, or {@code null} if no indicator was
*
registered with
the given {@code name}.
* @return the health indicator, or {@code null} if no indicator was
registered with
* the given {@code name}.
*/
ReactiveHealthIndicator
get
(
String
name
);
/**
* Returns a snapshot of the registered health indicators and their names.
* The contents of the map do not reflect subsequent changes to the
* registry.
* Returns a snapshot of the registered health indicators and their names. The
* contents of the map do not reflect subsequent changes to the registry.
* @return the snapshot of registered health indicators
*/
Map
<
String
,
ReactiveHealthIndicator
>
getAll
();
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorTests.java
View file @
3702da45
...
...
@@ -45,7 +45,7 @@ public class CompositeReactiveHealthIndicatorTests {
public
void
singleIndicator
()
{
CompositeReactiveHealthIndicator
indicator
=
new
CompositeReactiveHealthIndicator
(
this
.
healthAggregator
,
new
DefaultReactiveHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"test"
,
()
->
Mono
.
just
(
HEALTHY
))));
Collections
.
singletonMap
(
"test"
,
()
->
Mono
.
just
(
HEALTHY
))));
StepVerifier
.
create
(
indicator
.
health
()).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
h
.
getDetails
()).
containsOnlyKeys
(
"test"
);
...
...
@@ -64,9 +64,9 @@ public class CompositeReactiveHealthIndicatorTests {
new
DefaultReactiveHealthIndicatorRegistry
(
indicators
));
StepVerifier
.
withVirtualTime
(
indicator:
:
health
).
expectSubscription
()
.
thenAwait
(
Duration
.
ofMillis
(
10000
)).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
h
.
getDetails
()).
hasSize
(
50
);
}).
verifyComplete
();
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
h
.
getDetails
()).
hasSize
(
50
);
}).
verifyComplete
();
}
...
...
@@ -78,7 +78,7 @@ public class CompositeReactiveHealthIndicatorTests {
CompositeReactiveHealthIndicator
indicator
=
new
CompositeReactiveHealthIndicator
(
this
.
healthAggregator
,
new
DefaultReactiveHealthIndicatorRegistry
(
indicators
))
.
timeoutStrategy
(
100
,
UNKNOWN_HEALTH
);
.
timeoutStrategy
(
100
,
UNKNOWN_HEALTH
);
StepVerifier
.
create
(
indicator
.
health
()).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
h
.
getDetails
()).
containsOnlyKeys
(
"slow"
,
"fast"
);
...
...
@@ -95,14 +95,14 @@ public class CompositeReactiveHealthIndicatorTests {
CompositeReactiveHealthIndicator
indicator
=
new
CompositeReactiveHealthIndicator
(
this
.
healthAggregator
,
new
DefaultReactiveHealthIndicatorRegistry
(
indicators
))
.
timeoutStrategy
(
20000
,
null
);
.
timeoutStrategy
(
20000
,
null
);
StepVerifier
.
withVirtualTime
(
indicator:
:
health
).
expectSubscription
()
.
thenAwait
(
Duration
.
ofMillis
(
10000
)).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
h
.
getDetails
()).
containsOnlyKeys
(
"slow"
,
"fast"
);
assertThat
(
h
.
getDetails
().
get
(
"slow"
)).
isEqualTo
(
HEALTHY
);
assertThat
(
h
.
getDetails
().
get
(
"fast"
)).
isEqualTo
(
HEALTHY
);
}).
verifyComplete
();
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
h
.
getDetails
()).
containsOnlyKeys
(
"slow"
,
"fast"
);
assertThat
(
h
.
getDetails
().
get
(
"slow"
)).
isEqualTo
(
HEALTHY
);
assertThat
(
h
.
getDetails
().
get
(
"fast"
)).
isEqualTo
(
HEALTHY
);
}).
verifyComplete
();
}
static
class
TimeoutHealth
implements
ReactiveHealthIndicator
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistryTests.java
View file @
3702da45
...
...
@@ -47,10 +47,10 @@ public class DefaultReactiveHealthIndicatorRegistryTests {
@Before
public
void
setUp
()
{
given
(
this
.
one
.
health
()).
willReturn
(
Mono
.
just
(
new
Health
.
Builder
().
unknown
().
withDetail
(
"1"
,
"1"
).
build
()));
given
(
this
.
two
.
health
()).
willReturn
(
Mono
.
just
(
new
Health
.
Builder
().
unknown
().
withDetail
(
"2"
,
"2"
).
build
()));
given
(
this
.
one
.
health
()).
willReturn
(
Mono
.
just
(
new
Health
.
Builder
().
unknown
().
withDetail
(
"1"
,
"1"
).
build
()));
given
(
this
.
two
.
health
()).
willReturn
(
Mono
.
just
(
new
Health
.
Builder
().
unknown
().
withDetail
(
"2"
,
"2"
).
build
()));
this
.
registry
=
new
DefaultReactiveHealthIndicatorRegistry
();
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java
View file @
3702da45
...
...
@@ -59,8 +59,8 @@ public class HealthEndpointTests {
@Test
public
void
statusForComponentIsExposed
()
{
HealthEndpoint
endpoint
=
new
HealthEndpoint
(
createHealthIndicator
(
Collections
.
singletonMap
(
"test"
,
one
)));
HealthEndpoint
endpoint
=
new
HealthEndpoint
(
createHealthIndicator
(
Collections
.
singletonMap
(
"test"
,
one
)));
Health
health
=
endpoint
.
healthForComponent
(
"test"
);
assertThat
(
health
).
isNotNull
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
...
...
@@ -69,8 +69,8 @@ public class HealthEndpointTests {
@Test
public
void
statusForUnknownComponentReturnNull
()
{
HealthEndpoint
endpoint
=
new
HealthEndpoint
(
createHealthIndicator
(
Collections
.
emptyMap
()));
HealthEndpoint
endpoint
=
new
HealthEndpoint
(
createHealthIndicator
(
Collections
.
emptyMap
()));
Health
health
=
endpoint
.
healthForComponent
(
"does-not-exist"
);
assertThat
(
health
).
isNull
();
}
...
...
@@ -79,7 +79,7 @@ public class HealthEndpointTests {
public
void
statusForComponentInstanceIsExposed
()
{
CompositeHealthIndicator
compositeIndicator
=
new
CompositeHealthIndicator
(
new
OrderedHealthAggregator
(),
new
DefaultHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"sub"
,
()
->
Health
.
down
().
build
())));
Collections
.
singletonMap
(
"sub"
,
()
->
Health
.
down
().
build
())));
HealthEndpoint
endpoint
=
new
HealthEndpoint
(
createHealthIndicator
(
Collections
.
singletonMap
(
"test"
,
compositeIndicator
)));
Health
health
=
endpoint
.
healthForComponentInstance
(
"test"
,
"sub"
);
...
...
@@ -92,7 +92,7 @@ public class HealthEndpointTests {
public
void
statusForUnknownComponentInstanceReturnNull
()
{
CompositeHealthIndicator
compositeIndicator
=
new
CompositeHealthIndicator
(
new
OrderedHealthAggregator
(),
new
DefaultHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"sub"
,
()
->
Health
.
down
().
build
())));
Collections
.
singletonMap
(
"sub"
,
()
->
Health
.
down
().
build
())));
HealthEndpoint
endpoint
=
new
HealthEndpoint
(
createHealthIndicator
(
Collections
.
singletonMap
(
"test"
,
compositeIndicator
)));
Health
health
=
endpoint
.
healthForComponentInstance
(
"test"
,
"does-not-exist"
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java
View file @
3702da45
...
...
@@ -56,9 +56,9 @@ public class HealthEndpointWebIntegrationTests {
registry
.
register
(
"charlie"
,
()
->
Health
.
down
().
build
());
try
{
client
.
get
().
uri
(
"/actuator/health"
).
exchange
().
expectStatus
()
.
isEqualTo
(
HttpStatus
.
SERVICE_UNAVAILABLE
).
expectBody
()
.
jsonPath
(
"status"
)
.
isEqualTo
(
"DOWN"
).
jsonPath
(
"details.alpha.status"
).
isEqualTo
(
"UP
"
)
.
jsonPath
(
"details.bravo.status"
).
isEqualTo
(
"UP"
)
.
isEqualTo
(
HttpStatus
.
SERVICE_UNAVAILABLE
).
expectBody
()
.
jsonPath
(
"status"
).
isEqualTo
(
"DOWN"
).
jsonPath
(
"details.alpha.status
"
)
.
isEqualTo
(
"UP"
).
jsonPath
(
"details.bravo.status"
).
isEqualTo
(
"UP"
)
.
jsonPath
(
"details.charlie.status"
).
isEqualTo
(
"DOWN"
);
}
finally
{
...
...
@@ -71,9 +71,10 @@ public class HealthEndpointWebIntegrationTests {
HealthIndicatorRegistry
registry
=
context
.
getBean
(
HealthIndicatorRegistry
.
class
);
HealthIndicator
bravo
=
registry
.
unregister
(
"bravo"
);
try
{
client
.
get
().
uri
(
"/actuator/health"
).
exchange
().
expectStatus
().
isOk
().
expectBody
()
.
jsonPath
(
"status"
).
isEqualTo
(
"UP"
).
jsonPath
(
"details.alpha.status"
)
.
isEqualTo
(
"UP"
).
jsonPath
(
"details.bravo.status"
).
doesNotExist
();
client
.
get
().
uri
(
"/actuator/health"
).
exchange
().
expectStatus
().
isOk
()
.
expectBody
().
jsonPath
(
"status"
).
isEqualTo
(
"UP"
)
.
jsonPath
(
"details.alpha.status"
).
isEqualTo
(
"UP"
)
.
jsonPath
(
"details.bravo.status"
).
doesNotExist
();
}
finally
{
registry
.
register
(
"bravo"
,
bravo
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapperTests.java
View file @
3702da45
...
...
@@ -62,7 +62,8 @@ public class HealthWebEndpointResponseMapperTests {
@Test
public
void
mapDetailsWithUnauthorizedUserDoesNotInvokeSupplier
()
{
HealthWebEndpointResponseMapper
mapper
=
createMapper
(
ShowDetails
.
WHEN_AUTHORIZED
);
HealthWebEndpointResponseMapper
mapper
=
createMapper
(
ShowDetails
.
WHEN_AUTHORIZED
);
Supplier
<
Health
>
supplier
=
mockSupplier
();
SecurityContext
securityContext
=
mockSecurityContext
(
"USER"
);
WebEndpointResponse
<
Health
>
response
=
mapper
.
mapDetails
(
supplier
,
...
...
@@ -75,13 +76,15 @@ public class HealthWebEndpointResponseMapperTests {
@Test
public
void
mapDetailsWithAuthorizedUserInvokeSupplier
()
{
HealthWebEndpointResponseMapper
mapper
=
createMapper
(
ShowDetails
.
WHEN_AUTHORIZED
);
HealthWebEndpointResponseMapper
mapper
=
createMapper
(
ShowDetails
.
WHEN_AUTHORIZED
);
Supplier
<
Health
>
supplier
=
mockSupplier
();
given
(
supplier
.
get
()).
willReturn
(
Health
.
down
().
build
());
SecurityContext
securityContext
=
mockSecurityContext
(
"ACTUATOR"
);
WebEndpointResponse
<
Health
>
response
=
mapper
.
mapDetails
(
supplier
,
securityContext
);
assertThat
(
response
.
getStatus
()).
isEqualTo
(
HttpStatus
.
SERVICE_UNAVAILABLE
.
value
());
assertThat
(
response
.
getStatus
())
.
isEqualTo
(
HttpStatus
.
SERVICE_UNAVAILABLE
.
value
());
assertThat
(
response
.
getBody
().
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
verify
(
supplier
).
get
();
verify
(
securityContext
).
isUserInRole
(
"ACTUATOR"
);
...
...
@@ -108,12 +111,12 @@ public class HealthWebEndpointResponseMapperTests {
private
SecurityContext
mockSecurityContext
(
String
...
roles
)
{
List
<
String
>
associatedRoles
=
Arrays
.
asList
(
roles
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
anyString
()))
.
will
((
Answer
<
Boolean
>)
invocation
->
{
String
expectedRole
=
invocation
.
getArgument
(
0
);
return
associatedRoles
.
contains
(
expectedRole
);
});
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
anyString
()))
.
will
((
Answer
<
Boolean
>)
invocation
->
{
String
expectedRole
=
invocation
.
getArgument
(
0
);
return
associatedRoles
.
contains
(
expectedRole
);
});
return
securityContext
;
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistryFactoryTests.java
View file @
3702da45
...
...
@@ -39,16 +39,18 @@ public class ReactiveHealthIndicatorRegistryFactoryTests {
@Test
public
void
defaultHealthIndicatorNameFactory
()
{
ReactiveHealthIndicatorRegistry
registry
=
this
.
factory
.
createReactiveHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"myHealthIndicator"
,
()
->
Mono
.
just
(
UP
)),
null
);
ReactiveHealthIndicatorRegistry
registry
=
this
.
factory
.
createReactiveHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"myHealthIndicator"
,
()
->
Mono
.
just
(
UP
)),
null
);
assertThat
(
registry
.
getAll
()).
containsOnlyKeys
(
"my"
);
}
@Test
public
void
healthIndicatorIsAdapted
()
{
ReactiveHealthIndicatorRegistry
registry
=
this
.
factory
.
createReactiveHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"test"
,
()
->
Mono
.
just
(
UP
)),
Collections
.
singletonMap
(
"regular"
,
()
->
DOWN
));
ReactiveHealthIndicatorRegistry
registry
=
this
.
factory
.
createReactiveHealthIndicatorRegistry
(
Collections
.
singletonMap
(
"test"
,
()
->
Mono
.
just
(
UP
)),
Collections
.
singletonMap
(
"regular"
,
()
->
DOWN
));
assertThat
(
registry
.
getAll
()).
containsOnlyKeys
(
"test"
,
"regular"
);
StepVerifier
.
create
(
registry
.
get
(
"regular"
).
health
()).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientBuilderCustomizer.java
View file @
3702da45
...
...
@@ -34,4 +34,5 @@ public interface RestClientBuilderCustomizer {
* @param builder the builder to customize
*/
void
customize
(
RestClientBuilder
builder
);
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientProperties.java
View file @
3702da45
...
...
@@ -47,8 +47,6 @@ public class RestClientProperties {
*/
private
String
password
;
public
List
<
String
>
getUris
()
{
return
this
.
uris
;
}
...
...
@@ -72,4 +70,5 @@ public class RestClientProperties {
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java
View file @
3702da45
...
...
@@ -72,8 +72,8 @@ public class JestAutoConfigurationTests {
@Test
public
void
jestClientOnLocalhostByDefault
()
{
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
JestClient
.
class
));
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
JestClient
.
class
));
}
@Test
...
...
@@ -130,11 +130,12 @@ public class JestAutoConfigurationTests {
Map
<
String
,
String
>
source
=
new
HashMap
<>();
source
.
put
(
"a"
,
"alpha"
);
source
.
put
(
"b"
,
"bravo"
);
Index
index
=
new
Index
.
Builder
(
source
).
index
(
"foo"
)
.
type
(
"bar"
).
id
(
"1"
).
build
();
Index
index
=
new
Index
.
Builder
(
source
).
index
(
"foo"
)
.
type
(
"bar"
)
.
id
(
"1"
).
build
();
execute
(
client
,
index
);
Get
getRequest
=
new
Get
.
Builder
(
"foo"
,
"1"
).
build
();
assertThat
(
execute
(
client
,
getRequest
).
getResponseCode
()).
isEqualTo
(
200
);
assertThat
(
execute
(
client
,
getRequest
).
getResponseCode
())
.
isEqualTo
(
200
);
}));
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientAutoConfigurationTests.java
View file @
3702da45
...
...
@@ -100,6 +100,7 @@ public class RestClientAutoConfigurationTests {
public
RestClient
customRestClient
()
{
return
mock
(
RestClient
.
class
);
}
}
@Configuration
...
...
@@ -109,6 +110,7 @@ public class RestClientAutoConfigurationTests {
public
RestClientBuilderCustomizer
myCustomizer
()
{
return
(
builder
)
->
builder
.
setMaxRetryTimeoutMillis
(
42
);
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java
View file @
3702da45
...
...
@@ -181,15 +181,13 @@ public class LiquibaseAutoConfigurationTests {
@Test
public
void
overrideTestRollbackOnUpdate
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.liquibase.test-rollback-on-update:true"
)
.
withPropertyValues
(
"spring.liquibase.test-rollback-on-update:true"
)
.
run
((
context
)
->
{
SpringLiquibase
liquibase
=
context
.
getBean
(
SpringLiquibase
.
class
);
assertThat
(
liquibase
.
isTestRollbackOnUpdate
()).
isTrue
();
});
}
@Test
public
void
changeLogDoesNotExist
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java
View file @
3702da45
...
...
@@ -43,8 +43,7 @@ public class WebMvcTestPageableIntegrationTests {
@Test
public
void
shouldSupportPageable
()
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/paged"
).
param
(
"page"
,
"2"
).
param
(
"size"
,
"42"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
"2:42"
));
.
andExpect
(
status
().
isOk
()).
andExpect
(
content
().
string
(
"2:42"
));
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java
View file @
3702da45
...
...
@@ -267,7 +267,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
+
"]"
);
}
if
(
hasWorkingDirectorySet
())
{
getLog
().
warn
(
"Fork mode disabled, ignoring working directory configuration"
);
getLog
().
warn
(
"Fork mode disabled, ignoring working directory configuration"
);
}
}
}
...
...
@@ -475,7 +476,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private
void
logArguments
(
String
message
,
String
[]
args
)
{
if
(
getLog
().
isDebugEnabled
())
{
getLog
().
debug
(
Arrays
.
stream
(
args
).
collect
(
Collectors
.
joining
(
" "
,
message
,
""
)));
getLog
().
debug
(
Arrays
.
stream
(
args
).
collect
(
Collectors
.
joining
(
" "
,
message
,
""
)));
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java
View file @
3702da45
...
...
@@ -229,9 +229,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
}
/**
* Return the source {@link Artifact} to repackage. If a classifier is specified
* an
d an artifact with that classifier exists, it is used. Otherwise, the main
*
artifact
is used.
* Return the source {@link Artifact} to repackage. If a classifier is specified
and
* an
artifact with that classifier exists, it is used. Otherwise, the main artifact
* is used.
* @return the source artifact to repackage
*/
private
Artifact
getSourceArtifact
()
{
...
...
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