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
c4cba6b0
Commit
c4cba6b0
authored
Apr 12, 2017
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
97105770
c9726898
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
209 additions
and
157 deletions
+209
-157
LoggersMvcEndpoint.java
...amework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java
+7
-5
SolrHealthIndicator.java
...ingframework/boot/actuate/health/SolrHealthIndicator.java
+4
-7
WebRequestTraceFilter.java
...ngframework/boot/actuate/trace/WebRequestTraceFilter.java
+3
-5
TraceWebFilterAutoConfigurationTests.java
...e/autoconfigure/TraceWebFilterAutoConfigurationTests.java
+9
-9
SolrHealthIndicatorTests.java
...amework/boot/actuate/health/SolrHealthIndicatorTests.java
+5
-5
FreeMarkerTemplateAvailabilityProvider.java
...re/freemarker/FreeMarkerTemplateAvailabilityProvider.java
+15
-43
GroovyTemplateAvailabilityProvider.java
...e/groovy/template/GroovyTemplateAvailabilityProvider.java
+16
-43
AbstractTemplateAvailabilityProvider.java
...figure/template/AbstractTemplateAvailabilityProvider.java
+110
-0
ValidationAutoConfiguration.java
...autoconfigure/validation/ValidationAutoConfiguration.java
+2
-2
ValidationAutoConfigurationTests.java
...onfigure/validation/ValidationAutoConfigurationTests.java
+4
-4
production-ready-features.adoc
...oot-docs/src/main/asciidoc/production-ready-features.adoc
+32
-32
SampleActuatorApplicationTests.java
.../java/sample/actuator/SampleActuatorApplicationTests.java
+2
-2
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java
View file @
c4cba6b0
...
...
@@ -68,17 +68,19 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter {
// disabled
return
getDisabledResponse
();
}
LogLevel
logLevel
;
try
{
String
level
=
configuration
.
get
(
"configuredLevel"
);
logLevel
=
level
==
null
?
null
:
LogLevel
.
valueOf
(
level
.
toUpperCase
());
LogLevel
logLevel
=
getLogLevel
(
configuration
);
this
.
delegate
.
setLogLevel
(
name
,
logLevel
);
return
ResponseEntity
.
ok
().
build
();
}
catch
(
IllegalArgumentException
ex
)
{
return
ResponseEntity
.
badRequest
().
build
();
}
}
this
.
delegate
.
setLogLevel
(
name
,
logLevel
);
return
ResponseEntity
.
ok
().
build
();
private
LogLevel
getLogLevel
(
Map
<
String
,
String
>
configuration
)
{
String
level
=
configuration
.
get
(
"configuredLevel"
);
return
(
level
==
null
?
null
:
LogLevel
.
valueOf
(
level
.
toUpperCase
()));
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SolrHealthIndicator.java
View file @
c4cba6b0
...
...
@@ -41,13 +41,10 @@ public class SolrHealthIndicator extends AbstractHealthIndicator {
CoreAdminRequest
request
=
new
CoreAdminRequest
();
request
.
setAction
(
CoreAdminParams
.
CoreAdminAction
.
STATUS
);
CoreAdminResponse
response
=
request
.
process
(
this
.
solrClient
);
int
status
=
response
.
getStatus
();
if
(
status
==
0
)
{
builder
.
up
().
withDetail
(
"solrStatus"
,
"OK"
);
}
else
{
builder
.
down
().
withDetail
(
"solrStatus"
,
status
);
}
int
statusCode
=
response
.
getStatus
();
Status
status
=
(
statusCode
==
0
?
Status
.
UP
:
Status
.
DOWN
);
builder
.
status
(
status
).
withDetail
(
"solrStatus"
,
(
statusCode
==
0
?
"OK"
:
statusCode
));
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java
View file @
c4cba6b0
...
...
@@ -138,7 +138,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
add
(
trace
,
Include
.
USER_PRINCIPAL
,
"userPrincipal"
,
(
userPrincipal
==
null
?
null
:
userPrincipal
.
getName
()));
if
(
isIncluded
(
Include
.
PARAMETERS
))
{
trace
.
put
(
"parameters"
,
getParameterMap
(
request
));
trace
.
put
(
"parameters"
,
getParameterMap
Copy
(
request
));
}
add
(
trace
,
Include
.
QUERY_STRING
,
"query"
,
request
.
getQueryString
());
add
(
trace
,
Include
.
AUTH_TYPE
,
"authType"
,
request
.
getAuthType
());
...
...
@@ -190,10 +190,8 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
return
value
;
}
private
Map
<
String
,
String
[]>
getParameterMap
(
HttpServletRequest
request
)
{
Map
<
String
,
String
[]>
map
=
new
LinkedHashMap
<
String
,
String
[]>();
map
.
putAll
(
request
.
getParameterMap
());
return
map
;
private
Map
<
String
,
String
[]>
getParameterMapCopy
(
HttpServletRequest
request
)
{
return
new
LinkedHashMap
<
String
,
String
[]>(
request
.
getParameterMap
());
}
/**
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/TraceWebFilterAutoConfigurationTests.java
View file @
c4cba6b0
...
...
@@ -66,7 +66,7 @@ public class TraceWebFilterAutoConfigurationTests {
public
void
skipsFilterIfPropertyDisabled
()
throws
Exception
{
load
(
"endpoints.trace.filter.enabled:false"
);
assertThat
(
this
.
context
.
getBeansOfType
(
WebRequestTraceFilter
.
class
).
size
())
.
isEqualTo
(
0
);
.
isEqualTo
(
0
);
}
private
void
load
(
String
...
environment
)
{
...
...
@@ -74,16 +74,16 @@ public class TraceWebFilterAutoConfigurationTests {
}
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
AnnotationConfigApplicationContext
c
tx
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
c
tx
,
environment
);
AnnotationConfigApplicationContext
c
ontext
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
c
ontext
,
environment
);
if
(
config
!=
null
)
{
c
tx
.
register
(
config
);
c
ontext
.
register
(
config
);
}
c
tx
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
TraceRepositoryAutoConfiguration
.
class
,
TraceWebFilterAutoConfiguration
.
class
);
c
tx
.
refresh
();
this
.
context
=
c
tx
;
c
ontext
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
TraceRepositoryAutoConfiguration
.
class
,
TraceWebFilterAutoConfiguration
.
class
);
c
ontext
.
refresh
();
this
.
context
=
c
ontext
;
}
@Configuration
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/SolrHealthIndicatorTests.java
View file @
c4cba6b0
...
...
@@ -31,9 +31,9 @@ import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isNull
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
isNull
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
...
...
@@ -68,7 +68,7 @@ public class SolrHealthIndicatorTests {
public
void
solrIsUp
()
throws
Exception
{
SolrClient
solrClient
=
mock
(
SolrClient
.
class
);
given
(
solrClient
.
request
(
any
(
CoreAdminRequest
.
class
),
isNull
()))
.
willReturn
(
mockResponse
(
0
));
.
willReturn
(
mockResponse
(
0
));
SolrHealthIndicator
healthIndicator
=
new
SolrHealthIndicator
(
solrClient
);
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
...
...
@@ -79,7 +79,7 @@ public class SolrHealthIndicatorTests {
public
void
solrIsUpAndRequestFailed
()
throws
Exception
{
SolrClient
solrClient
=
mock
(
SolrClient
.
class
);
given
(
solrClient
.
request
(
any
(
CoreAdminRequest
.
class
),
isNull
()))
.
willReturn
(
mockResponse
(
400
));
.
willReturn
(
mockResponse
(
400
));
SolrHealthIndicator
healthIndicator
=
new
SolrHealthIndicator
(
solrClient
);
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
...
...
@@ -90,7 +90,7 @@ public class SolrHealthIndicatorTests {
public
void
solrIsDown
()
throws
Exception
{
SolrClient
solrClient
=
mock
(
SolrClient
.
class
);
given
(
solrClient
.
request
(
any
(
CoreAdminRequest
.
class
),
isNull
()))
.
willThrow
(
new
IOException
(
"Connection failed"
));
.
willThrow
(
new
IOException
(
"Connection failed"
));
SolrHealthIndicator
healthIndicator
=
new
SolrHealthIndicator
(
solrClient
);
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java
View file @
c4cba6b0
...
...
@@ -20,13 +20,8 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
java.util.List
;
import
org.springframework.boot.autoconfigure.template.AbstractTemplateAvailabilityProvider
;
import
org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider
;
import
org.springframework.boot.bind.PropertySourcesPropertyValues
;
import
org.springframework.boot.bind.RelaxedDataBinder
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.util.ClassUtils
;
/**
* {@link TemplateAvailabilityProvider} that provides availability information for
...
...
@@ -36,35 +31,28 @@ import org.springframework.util.ClassUtils;
* @since 1.1.0
*/
public
class
FreeMarkerTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
extends
Abstract
TemplateAvailabilityProvider
{
@Override
public
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
if
(
ClassUtils
.
isPresent
(
"freemarker.template.Configuration"
,
classLoader
))
{
FreeMarkerTemplateAvailabilityProperties
properties
=
new
FreeMarkerTemplateAvailabilityProperties
();
RelaxedDataBinder
binder
=
new
RelaxedDataBinder
(
properties
,
"spring.freemarker"
);
binder
.
bind
(
new
PropertySourcesPropertyValues
(
((
ConfigurableEnvironment
)
environment
).
getPropertySources
()));
for
(
String
loaderPath
:
properties
.
getTemplateLoaderPath
())
{
if
(
resourceLoader
.
getResource
(
loaderPath
+
properties
.
getPrefix
()
+
view
+
properties
.
getSuffix
()).
exists
())
{
return
true
;
}
}
}
return
false
;
public
FreeMarkerTemplateAvailabilityProvider
()
{
super
(
"freemarker.template.Configuration"
,
FreeMarkerTemplateAvailabilityProperties
.
class
,
"spring.freemarker"
);
}
static
final
class
FreeMarkerTemplateAvailabilityProperties
{
static
final
class
FreeMarkerTemplateAvailabilityProperties
extends
TemplateAvailabilityProperties
{
private
List
<
String
>
templateLoaderPath
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
FreeMarkerProperties
.
DEFAULT_TEMPLATE_LOADER_PATH
));
private
String
prefix
=
FreeMarkerProperties
.
DEFAULT_PREFIX
;
FreeMarkerTemplateAvailabilityProperties
()
{
super
(
FreeMarkerProperties
.
DEFAULT_PREFIX
,
FreeMarkerProperties
.
DEFAULT_SUFFIX
);
}
private
String
suffix
=
FreeMarkerProperties
.
DEFAULT_SUFFIX
;
@Override
protected
List
<
String
>
getLoaderPath
()
{
return
this
.
templateLoaderPath
;
}
public
List
<
String
>
getTemplateLoaderPath
()
{
return
this
.
templateLoaderPath
;
...
...
@@ -74,22 +62,6 @@ public class FreeMarkerTemplateAvailabilityProvider
this
.
templateLoaderPath
=
templateLoaderPath
;
}
public
String
getPrefix
()
{
return
this
.
prefix
;
}
public
void
setPrefix
(
String
prefix
)
{
this
.
prefix
=
prefix
;
}
public
String
getSuffix
()
{
return
this
.
suffix
;
}
public
void
setSuffix
(
String
suffix
)
{
this
.
suffix
=
suffix
;
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java
View file @
c4cba6b0
...
...
@@ -20,13 +20,8 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
java.util.List
;
import
org.springframework.boot.autoconfigure.template.AbstractTemplateAvailabilityProvider
;
import
org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider
;
import
org.springframework.boot.bind.PropertySourcesPropertyValues
;
import
org.springframework.boot.bind.RelaxedDataBinder
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.util.ClassUtils
;
/**
* {@link TemplateAvailabilityProvider} that provides availability information for Groovy
...
...
@@ -35,35 +30,29 @@ import org.springframework.util.ClassUtils;
* @author Dave Syer
* @since 1.1.0
*/
public
class
GroovyTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
public
class
GroovyTemplateAvailabilityProvider
extends
AbstractTemplateAvailabilityProvider
{
@Override
public
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
if
(
ClassUtils
.
isPresent
(
"groovy.text.TemplateEngine"
,
classLoader
))
{
GroovyTemplateAvailabilityProperties
properties
=
new
GroovyTemplateAvailabilityProperties
();
RelaxedDataBinder
binder
=
new
RelaxedDataBinder
(
properties
,
"spring.groovy.template"
);
binder
.
bind
(
new
PropertySourcesPropertyValues
(
((
ConfigurableEnvironment
)
environment
).
getPropertySources
()));
for
(
String
loaderPath
:
properties
.
getResourceLoaderPath
())
{
if
(
resourceLoader
.
getResource
(
loaderPath
+
properties
.
getPrefix
()
+
view
+
properties
.
getSuffix
()).
exists
())
{
return
true
;
}
}
}
return
false
;
public
GroovyTemplateAvailabilityProvider
()
{
super
(
"groovy.text.TemplateEngine"
,
GroovyTemplateAvailabilityProperties
.
class
,
"spring.groovy.template"
);
}
static
final
class
GroovyTemplateAvailabilityProperties
{
static
final
class
GroovyTemplateAvailabilityProperties
extends
TemplateAvailabilityProperties
{
private
List
<
String
>
resourceLoaderPath
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
GroovyTemplateProperties
.
DEFAULT_RESOURCE_LOADER_PATH
));
private
String
prefix
=
GroovyTemplateProperties
.
DEFAULT_PREFIX
;
GroovyTemplateAvailabilityProperties
()
{
super
(
GroovyTemplateProperties
.
DEFAULT_PREFIX
,
GroovyTemplateProperties
.
DEFAULT_SUFFIX
);
}
private
String
suffix
=
GroovyTemplateProperties
.
DEFAULT_SUFFIX
;
@Override
protected
List
<
String
>
getLoaderPath
()
{
return
this
.
resourceLoaderPath
;
}
public
List
<
String
>
getResourceLoaderPath
()
{
return
this
.
resourceLoaderPath
;
...
...
@@ -73,22 +62,6 @@ public class GroovyTemplateAvailabilityProvider implements TemplateAvailabilityP
this
.
resourceLoaderPath
=
resourceLoaderPath
;
}
public
String
getPrefix
()
{
return
this
.
prefix
;
}
public
void
setPrefix
(
String
prefix
)
{
this
.
prefix
=
prefix
;
}
public
String
getSuffix
()
{
return
this
.
suffix
;
}
public
void
setSuffix
(
String
suffix
)
{
this
.
suffix
=
suffix
;
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateAvailabilityProvider.java
0 → 100644
View file @
c4cba6b0
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
template
;
import
java.util.List
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.boot.bind.PropertySourcesPropertyValues
;
import
org.springframework.boot.bind.RelaxedDataBinder
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.util.ClassUtils
;
/**
* Abstract base class for {@link TemplateAvailabilityProvider} implementations.
*
* @author Andy Wilkinson
* @author Phillip Webb
* @since 1.4.6
*/
public
abstract
class
AbstractTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
private
final
String
className
;
private
final
Class
<?
extends
TemplateAvailabilityProperties
>
propertiesClass
;
private
final
String
propertyPrefix
;
public
AbstractTemplateAvailabilityProvider
(
String
className
,
Class
<?
extends
TemplateAvailabilityProperties
>
propertiesClass
,
String
propertyPrefix
)
{
this
.
className
=
className
;
this
.
propertiesClass
=
propertiesClass
;
this
.
propertyPrefix
=
propertyPrefix
;
}
@Override
public
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
if
(
ClassUtils
.
isPresent
(
this
.
className
,
classLoader
))
{
TemplateAvailabilityProperties
properties
=
BeanUtils
.
instantiateClass
(
this
.
propertiesClass
);
RelaxedDataBinder
binder
=
new
RelaxedDataBinder
(
properties
,
this
.
propertyPrefix
);
binder
.
bind
(
new
PropertySourcesPropertyValues
(
((
ConfigurableEnvironment
)
environment
).
getPropertySources
()));
return
isTemplateAvailable
(
view
,
resourceLoader
,
properties
);
}
return
false
;
}
private
boolean
isTemplateAvailable
(
String
view
,
ResourceLoader
resourceLoader
,
TemplateAvailabilityProperties
properties
)
{
String
location
=
properties
.
getPrefix
()
+
view
+
properties
.
getSuffix
();
for
(
String
path
:
properties
.
getLoaderPath
())
{
if
(
resourceLoader
.
getResource
(
path
+
location
).
exists
())
{
return
true
;
}
}
return
false
;
}
protected
static
abstract
class
TemplateAvailabilityProperties
{
private
String
prefix
;
private
String
suffix
;
protected
TemplateAvailabilityProperties
(
String
prefix
,
String
suffix
)
{
this
.
prefix
=
prefix
;
this
.
suffix
=
suffix
;
}
protected
abstract
List
<
String
>
getLoaderPath
();
public
String
getPrefix
()
{
return
this
.
prefix
;
}
public
void
setPrefix
(
String
prefix
)
{
this
.
prefix
=
prefix
;
}
public
String
getSuffix
()
{
return
this
.
suffix
;
}
public
void
setSuffix
(
String
suffix
)
{
this
.
suffix
=
suffix
;
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java
View file @
c4cba6b0
...
...
@@ -66,8 +66,8 @@ public class ValidationAutoConfiguration {
}
private
static
boolean
determineProxyTargetClass
(
Environment
environment
)
{
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
environment
,
"spring.aop."
);
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
environment
,
"spring.aop."
);
Boolean
value
=
resolver
.
getProperty
(
"proxyTargetClass"
,
Boolean
.
class
);
return
(
value
!=
null
?
value
:
true
);
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationTests.java
View file @
c4cba6b0
...
...
@@ -78,12 +78,12 @@ public class ValidationAutoConfigurationTests {
@Test
public
void
validationCanBeConfiguredToUseJdkProxy
()
{
load
(
AnotherSampleServiceConfiguration
.
class
,
"spring.aop.proxy-target-class=false"
);
load
(
AnotherSampleServiceConfiguration
.
class
,
"spring.aop.proxy-target-class=false"
);
assertThat
(
this
.
context
.
getBeansOfType
(
Validator
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
DefaultAnotherSampleService
.
class
))
.
isEmpty
();
AnotherSampleService
service
=
this
.
context
.
getBean
(
AnotherSampleService
.
class
);
.
isEmpty
();
AnotherSampleService
service
=
this
.
context
.
getBean
(
AnotherSampleService
.
class
);
service
.
doSomething
(
42
);
this
.
thrown
.
expect
(
ConstraintViolationException
.
class
);
service
.
doSomething
(
2
);
...
...
spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
View file @
c4cba6b0
...
...
@@ -726,52 +726,52 @@ Sample summarized HTTP response (default for anonymous request):
[source,indent=0]
----
$ curl -i localhost:8080/health
HTTP/1.1 200
X-Application-Context: application
Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8
Content-Length: 15
$ curl -i localhost:8080/health
HTTP/1.1 200
X-Application-Context: application
Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8
Content-Length: 15
{"status":"UP"}
{"status":"UP"}
----
Sample summarized HTTP response for status "DOWN" (notice the 503 status code):
[source,indent=0]
----
$ curl -i localhost:8080/health
HTTP/1.1 503
X-Application-Context: application
Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8
Content-Length: 17
$ curl -i localhost:8080/health
HTTP/1.1 503
X-Application-Context: application
Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8
Content-Length: 17
{"status":"DOWN"}
{"status":"DOWN"}
----
Sample detailed HTTP response:
[source,indent=0]
----
$ curl -i localhost:8080/health
HTTP/1.1 200 OK
X-Application-Context: application
Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8
Content-Length: 221
{
"status" : "UP",
"diskSpace" : {
"status" : "UP",
"total" : 63251804160,
"free" : 31316164608,
"threshold" : 10485760
},
"db" : {
"status" : "UP",
"database" : "H2",
"hello" : 1
}
}
$ curl -i localhost:8080/health
HTTP/1.1 200 OK
X-Application-Context: application
Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8
Content-Length: 221
{
"status" : "UP",
"diskSpace" : {
"status" : "UP",
"total" : 63251804160,
"free" : 31316164608,
"threshold" : 10485760
},
"db" : {
"status" : "UP",
"database" : "H2",
"hello" : 1
}
}
----
The above-described restrictions can be enhanced, thereby allowing only authenticated
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java
View file @
c4cba6b0
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
@@ -198,7 +198,7 @@ public class SampleActuatorApplicationTests {
List
<
Map
<
String
,
Object
>>
list
=
entity
.
getBody
();
Map
<
String
,
Object
>
trace
=
list
.
get
(
0
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
trace
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
trace
.
get
(
"info"
)).
get
(
"parameters"
);
assertThat
(
map
.
get
(
"param1"
)).
isNotNull
();
}
...
...
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