Skip to content

Commit 617c973

Browse files
committed
Allow endpoint paths to be configured via endpoint.<name>.path
Support for configuring an endpoint’s path separately from its id was introduced in 9725578, but it didn’t work for a variety of reasons: 1. Some custom MVC endpoints did not have configuration properties bound to them 2. Some generic endpoints rejected the path property as they were configured not to ignore unknown fields 3. The property used to configure the path was dependent on the id of the endpoint. This meant that the path property’s name would change if the endpoint’s id was changed This commit addresses these problems: 1. @ConfigurationProperties has been added to custom MvcEndpoints where it was missing 2. Generic endpoints have been updated to ignore unknown fields, allowing the path of their MVC adapter to be configured 3. Rather than using the id of a generic endpoint to determine the name of its path property, the prefix or value of the endpoint’s @ConfigurationProperties annotation is used instead. Any generic endpoint that is not annotated with @ConfigurationProperties is ignored, making its path unconfigurable. Closes gh-5105
1 parent c4205d0 commit 617c973

25 files changed

+277
-38
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
4444
* @author Dave Syer
4545
* @author Andy Wilkinson
4646
*/
47-
@ConfigurationProperties(prefix = "endpoints.autoconfig", ignoreUnknownFields = false)
47+
@ConfigurationProperties(prefix = "endpoints.autoconfig")
4848
public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
4949

5050
@Autowired

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/BeansEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@
3535
*
3636
* @author Dave Syer
3737
*/
38-
@ConfigurationProperties(prefix = "endpoints.beans", ignoreUnknownFields = false)
38+
@ConfigurationProperties(prefix = "endpoints.beans")
3939
public class BeansEndpoint extends AbstractEndpoint<List<Object>>
4040
implements ApplicationContextAware {
4141

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
5858
* @author Christian Dupuis
5959
* @author Dave Syer
6060
*/
61-
@ConfigurationProperties(prefix = "endpoints.configprops", ignoreUnknownFields = false)
61+
@ConfigurationProperties(prefix = "endpoints.configprops")
6262
public class ConfigurationPropertiesReportEndpoint
6363
extends AbstractEndpoint<Map<String, Object>> implements ApplicationContextAware {
6464

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/DumpEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
*
2929
* @author Dave Syer
3030
*/
31-
@ConfigurationProperties(prefix = "endpoints.dump", ignoreUnknownFields = false)
31+
@ConfigurationProperties(prefix = "endpoints.dump")
3232
public class DumpEndpoint extends AbstractEndpoint<List<ThreadInfo>> {
3333

3434
/**

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
3636
* @author Phillip Webb
3737
* @author Christian Dupuis
3838
*/
39-
@ConfigurationProperties(prefix = "endpoints.env", ignoreUnknownFields = false)
39+
@ConfigurationProperties(prefix = "endpoints.env")
4040
public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
4141

4242
private final Sanitizer sanitizer = new Sanitizer();

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/FlywayEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
3636
* @author Phillip Webb
3737
* @since 1.3.0
3838
*/
39-
@ConfigurationProperties(prefix = "endpoints.flyway", ignoreUnknownFields = true)
39+
@ConfigurationProperties(prefix = "endpoints.flyway")
4040
public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> {
4141

4242
private final Flyway flyway;

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@
3232
* @author Christian Dupuis
3333
* @author Andy Wilkinson
3434
*/
35-
@ConfigurationProperties(prefix = "endpoints.health", ignoreUnknownFields = true)
35+
@ConfigurationProperties(prefix = "endpoints.health")
3636
public class HealthEndpoint extends AbstractEndpoint<Health> {
3737

3838
private final HealthIndicator healthIndicator;

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
*
2929
* @author Dave Syer
3030
*/
31-
@ConfigurationProperties(prefix = "endpoints.info", ignoreUnknownFields = false)
31+
@ConfigurationProperties(prefix = "endpoints.info")
3232
public class InfoEndpoint extends AbstractEndpoint<Map<String, Object>> {
3333

3434
private final Map<String, ? extends Object> info;

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LiquibaseEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
3636
* @author Eddú Meléndez
3737
* @since 1.3.0
3838
*/
39-
@ConfigurationProperties(prefix = "endpoints.liquibase", ignoreUnknownFields = true)
39+
@ConfigurationProperties(prefix = "endpoints.liquibase")
4040
public class LiquibaseEndpoint extends AbstractEndpoint<List<Map<String, ?>>> {
4141

4242
private final SpringLiquibase liquibase;

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* @author Dave Syer
3939
* @author Andy Wilkinson
4040
*/
41-
@ConfigurationProperties(prefix = "endpoints.mappings", ignoreUnknownFields = false)
41+
@ConfigurationProperties(prefix = "endpoints.mappings")
4242
public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>>
4343
implements ApplicationContextAware {
4444

0 commit comments

Comments
 (0)