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
b2c3e7e2
Commit
b2c3e7e2
authored
Oct 01, 2015
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename error.* properties to server.error.*
Closes gh-4050
parent
4b138917
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
29 deletions
+42
-29
EndpointWebMvcChildContextConfiguration.java
...utoconfigure/EndpointWebMvcChildContextConfiguration.java
+4
-10
BasicErrorController.java
...ramework/boot/autoconfigure/web/BasicErrorController.java
+2
-2
ErrorMvcAutoConfiguration.java
...ork/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
+4
-7
ErrorProperties.java
...ringframework/boot/autoconfigure/web/ErrorProperties.java
+2
-2
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+7
-0
additional-spring-configuration-metadata.json
...es/META-INF/additional-spring-configuration-metadata.json
+14
-0
BasicErrorControllerDirectMockMvcTests.java
...configure/web/BasicErrorControllerDirectMockMvcTests.java
+1
-1
BasicErrorControllerIntegrationTests.java
...toconfigure/web/BasicErrorControllerIntegrationTests.java
+3
-3
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+3
-2
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+1
-1
application-endpoints.properties
...uator/src/test/resources/application-endpoints.properties
+1
-1
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcChildContextConfiguration.java
View file @
b2c3e7e2
...
...
@@ -31,7 +31,6 @@ import org.springframework.beans.factory.BeanFactoryUtils;
import
org.springframework.beans.factory.HierarchicalBeanFactory
;
import
org.springframework.beans.factory.ListableBeanFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration.ManagementWebSecurityConfigurerAdapter
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping
;
import
org.springframework.boot.actuate.endpoint.mvc.ManagementErrorEndpoint
;
...
...
@@ -83,9 +82,6 @@ public class EndpointWebMvcChildContextConfiguration {
private
static
Log
logger
=
LogFactory
.
getLog
(
EndpointWebMvcChildContextConfiguration
.
class
);
@Value
(
"${error.path:/error}"
)
private
String
errorPath
=
"/error"
;
@Bean
(
name
=
DispatcherServletAutoConfiguration
.
DEFAULT_DISPATCHER_SERVLET_BEAN_NAME
)
public
DispatcherServlet
dispatcherServlet
()
{
DispatcherServlet
dispatcherServlet
=
new
DispatcherServlet
();
...
...
@@ -123,8 +119,9 @@ public class EndpointWebMvcChildContextConfiguration {
* disabled. So we expose the same feature but only for machine endpoints.
*/
@Bean
public
ManagementErrorEndpoint
errorEndpoint
(
final
ErrorAttributes
errorAttributes
)
{
return
new
ManagementErrorEndpoint
(
this
.
errorPath
,
errorAttributes
);
public
ManagementErrorEndpoint
errorEndpoint
(
ServerProperties
serverProperties
,
final
ErrorAttributes
errorAttributes
)
{
return
new
ManagementErrorEndpoint
(
serverProperties
.
getError
().
getPath
(),
errorAttributes
);
}
/**
...
...
@@ -208,9 +205,6 @@ public class EndpointWebMvcChildContextConfiguration {
static
class
ServerCustomization
implements
EmbeddedServletContainerCustomizer
,
Ordered
{
@Value
(
"${error.path:/error}"
)
private
String
errorPath
=
"/error"
;
@Autowired
private
ListableBeanFactory
beanFactory
;
...
...
@@ -242,7 +236,7 @@ public class EndpointWebMvcChildContextConfiguration {
// and add the management-specific bits
container
.
setPort
(
this
.
managementServerProperties
.
getPort
());
container
.
setAddress
(
this
.
managementServerProperties
.
getAddress
());
container
.
addErrorPages
(
new
ErrorPage
(
this
.
errorPath
));
container
.
addErrorPages
(
new
ErrorPage
(
this
.
server
.
getError
().
getPath
()
));
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java
View file @
b2c3e7e2
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
...
@@ -45,7 +45,7 @@ import org.springframework.web.servlet.ModelAndView;
* @see ErrorProperties
*/
@Controller
@RequestMapping
(
"${
error.path:/error
}"
)
@RequestMapping
(
"${
server.error.path:${error.path:/error}
}"
)
public
class
BasicErrorController
extends
AbstractErrorController
{
private
final
ErrorProperties
errorProperties
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
View file @
b2c3e7e2
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
...
@@ -75,9 +75,6 @@ import org.springframework.web.util.HtmlUtils;
public
class
ErrorMvcAutoConfiguration
implements
EmbeddedServletContainerCustomizer
,
Ordered
{
@Autowired
private
ErrorProperties
errorProperties
;
@Autowired
private
ServerProperties
properties
;
...
...
@@ -95,17 +92,17 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
@Bean
@ConditionalOnMissingBean
(
value
=
ErrorController
.
class
,
search
=
SearchStrategy
.
CURRENT
)
public
BasicErrorController
basicErrorController
(
ErrorAttributes
errorAttributes
)
{
return
new
BasicErrorController
(
errorAttributes
,
this
.
errorProperties
);
return
new
BasicErrorController
(
errorAttributes
,
this
.
properties
.
getError
()
);
}
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
container
.
addErrorPages
(
new
ErrorPage
(
this
.
properties
.
getServletPrefix
()
+
this
.
errorProperties
.
getPath
()));
+
this
.
properties
.
getError
()
.
getPath
()));
}
@Configuration
@ConditionalOnProperty
(
prefix
=
"error.whitelabel"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"
server.
error.whitelabel"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@Conditional
(
ErrorTemplateMissingCondition
.
class
)
protected
static
class
WhitelabelErrorViewConfiguration
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java
View file @
b2c3e7e2
...
...
@@ -16,7 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
import
org.springframework.b
oot.context.properties.ConfigurationProperties
;
import
org.springframework.b
eans.factory.annotation.Value
;
/**
* Configuration properties for web error handling.
...
...
@@ -25,12 +25,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Stephane Nicoll
* @since 1.3.0
*/
@ConfigurationProperties
(
"error"
)
public
class
ErrorProperties
{
/**
* Path of the error controller.
*/
@Value
(
"${error.path:/error}"
)
private
String
path
=
"/error"
;
/**
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
b2c3e7e2
...
...
@@ -96,6 +96,9 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer,
*/
private
String
displayName
=
"application"
;
@NestedConfigurationProperty
private
ErrorProperties
error
=
new
ErrorProperties
();
/**
* Path of the main dispatcher servlet.
*/
...
...
@@ -328,6 +331,10 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer,
this
.
session
.
setTimeout
(
sessionTimeout
);
}
public
ErrorProperties
getError
()
{
return
this
.
error
;
}
public
Session
getSession
()
{
return
this
.
session
;
}
...
...
spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
View file @
b2c3e7e2
{
"properties"
:
[
{
"name"
:
"error.path"
,
"type"
:
"java.lang.String"
,
"description"
:
"Path of the error controller."
,
"deprecation"
:
{
"replacement"
:
"server.error.path"
}
},
{
"name"
:
"multipart.enabled"
,
"type"
:
"java.lang.Boolean"
,
"description"
:
"Enable support of multi-part uploads."
,
"defaultValue"
:
true
},
{
"name"
:
"server.error.whitelabel.enabled"
,
"type"
:
"java.lang.Boolean"
,
"description"
:
"Enable the default error page displayed in browsers in case of a server error."
,
"defaultValue"
:
true
},
{
"name"
:
"spring.aop.auto"
,
"type"
:
"java.lang.Boolean"
,
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerDirectMockMvcTests.java
View file @
b2c3e7e2
...
...
@@ -99,7 +99,7 @@ public class BasicErrorControllerDirectMockMvcTests {
public
void
errorPageNotAvailableWithWhitelabelDisabled
()
throws
Exception
{
setup
((
ConfigurableWebApplicationContext
)
new
SpringApplication
(
WebMvcIncludedConfiguration
.
class
).
run
(
"--server.port=0"
,
"--error.whitelabel.enabled=false"
));
"--
server.
error.whitelabel.enabled=false"
));
this
.
thrown
.
expect
(
ServletException
.
class
);
this
.
mockMvc
.
perform
(
get
(
"/error"
).
accept
(
MediaType
.
TEXT_HTML
));
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java
View file @
b2c3e7e2
...
...
@@ -95,7 +95,7 @@ public class BasicErrorControllerIntegrationTests {
@Test
@SuppressWarnings
(
"rawtypes"
)
public
void
testErrorForMachineClientTracePramamStacktrace
()
throws
Exception
{
load
(
"--error.include-stacktrace=on-trace-param"
);
load
(
"--
server.
error.include-stacktrace=on-trace-param"
);
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"?trace=true"
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"500"
,
""
+
"Internal Server Error"
,
...
...
@@ -106,7 +106,7 @@ public class BasicErrorControllerIntegrationTests {
@Test
@SuppressWarnings
(
"rawtypes"
)
public
void
testErrorForMachineClientNoStacktrace
()
throws
Exception
{
load
(
"--error.include-stacktrace=never"
);
load
(
"--
server.
error.include-stacktrace=never"
);
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"?trace=true"
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"500"
,
""
+
"Internal Server Error"
,
...
...
@@ -118,7 +118,7 @@ public class BasicErrorControllerIntegrationTests {
@Test
@SuppressWarnings
(
"rawtypes"
)
public
void
testErrorForMachineClientAlwaysStacktrace
()
throws
Exception
{
load
(
"--error.include-stacktrace=always"
);
load
(
"--
server.
error.include-stacktrace=always"
);
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"?trace=false"
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"500"
,
""
+
"Internal Server Error"
,
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
b2c3e7e2
...
...
@@ -139,8 +139,9 @@ content into your application; rather pick only the properties that you need.
server.undertow.worker-threads= # number of worker threads
# ERROR HANDLING ({sc-spring-boot-autoconfigure}/web/ErrorProperties.{sc-ext}[ErrorProperties])
error.path=/error # the error path
error.include-stacktrace=never # when to include a stacktrace attribute (never/alway/on-trace-param)
server.error.path=/error # the error path
server.error.include-stacktrace=never # when to include a stacktrace attribute (never/alway/on-trace-param)
server.error.whitelabel.enabled=true # enable the default error page displayed in browsers in case of a server error
# SPRING MVC ({sc-spring-boot-autoconfigure}/web/WebMvcProperties.{sc-ext}[WebMvcProperties])
spring.mvc.locale= # set fixed locale, e.g. en_UK
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
b2c3e7e2
...
...
@@ -1744,7 +1744,7 @@ in the '`Production-ready features`' section.
Spring Boot installs a '`whitelabel`' error page that you will see in browser client if
you encounter a server error (machine clients consuming JSON and other media types should
see a sensible response with the right error code). To switch it off you can set
`error.whitelabel.enabled=false`, but normally in addition or alternatively to that you
`
server.
error.whitelabel.enabled=false`, but normally in addition or alternatively to that you
will want to add your own error page replacing the whitelabel one. Exactly how you do this
depends on the templating technology that you are using. For example, if you are using
Thymeleaf you would add an `error.html` template and if you are using FreeMarker you would
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/resources/application-endpoints.properties
View file @
b2c3e7e2
error.path
:
/oops
server.
error.path
:
/oops
management.context-path
:
/admin
endpoints.health.sensitive
:
false
\ No newline at end of file
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