Rename error.* properties to server.error.*
Closes gh-4050
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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 {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.web;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.beans.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";
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
{"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",
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user