Commit 99b3240a authored by Christian Dupuis's avatar Christian Dupuis

Ensure custom HTTP code mappings for /health don't remove default mappings

Previously any custom http code mapping would remove the default mappings. With this commit the behaviour is changed so that default mappings will stay if a custom mapping is registered. Certainly a default mapping can be overridden.

fixes #1264
parent 5e02ee69
...@@ -157,7 +157,7 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, ...@@ -157,7 +157,7 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
public HealthMvcEndpoint healthMvcEndpoint(HealthEndpoint delegate) { public HealthMvcEndpoint healthMvcEndpoint(HealthEndpoint delegate) {
HealthMvcEndpoint healthMvcEndpoint = new HealthMvcEndpoint(delegate); HealthMvcEndpoint healthMvcEndpoint = new HealthMvcEndpoint(delegate);
if (this.healthMvcEndpointProperties.getMapping() != null) { if (this.healthMvcEndpointProperties.getMapping() != null) {
healthMvcEndpoint.setStatusMapping(this.healthMvcEndpointProperties healthMvcEndpoint.addStatusMapping(this.healthMvcEndpointProperties
.getMapping()); .getMapping());
} }
return healthMvcEndpoint; return healthMvcEndpoint;
......
...@@ -50,7 +50,7 @@ public class HealthMvcEndpoint extends EndpointMvcAdapter { ...@@ -50,7 +50,7 @@ public class HealthMvcEndpoint extends EndpointMvcAdapter {
} }
/** /**
* Set specific status mappings * Set specific status mappings.
* @param statusMapping a map of status code to {@link HttpStatus} * @param statusMapping a map of status code to {@link HttpStatus}
*/ */
public void setStatusMapping(Map<String, HttpStatus> statusMapping) { public void setStatusMapping(Map<String, HttpStatus> statusMapping) {
...@@ -59,7 +59,16 @@ public class HealthMvcEndpoint extends EndpointMvcAdapter { ...@@ -59,7 +59,16 @@ public class HealthMvcEndpoint extends EndpointMvcAdapter {
} }
/** /**
* Add a status mapping to the existing set * Add specfic status mappings to the existing set.
* @param statusMapping a map of status code to {@link HttpStatus}
*/
public void addStatusMapping(Map<String, HttpStatus> statusMapping) {
Assert.notNull(statusMapping, "StatusMapping must not be null");
this.statusMapping.putAll(statusMapping);
}
/**
* Add a status mapping to the existing set.
* @param status the status to map * @param status the status to map
* @param httpStatus the http status * @param httpStatus the http status
*/ */
...@@ -70,7 +79,7 @@ public class HealthMvcEndpoint extends EndpointMvcAdapter { ...@@ -70,7 +79,7 @@ public class HealthMvcEndpoint extends EndpointMvcAdapter {
} }
/** /**
* Add a status mapping to the existing set * Add a status mapping to the existing set.
* @param statusCode the status code to map * @param statusCode the status code to map
* @param httpStatus the http status * @param httpStatus the http status
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment