Skip to content

Commit a00ee15

Browse files
committed
Use lowercase default endpoint paths
Update `MappingWebEndpointPathMapper` to use the lowercase version of the endpoint ID when no explicit path mapping has been set. An endpoint with the ID 'myEndpoint' will now be mapped to the path 'myendpoint'. See gh-14773
1 parent df5dfbf commit a00ee15

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.boot.actuate.autoconfigure.endpoint.web;
1818

19+
import java.util.HashMap;
1920
import java.util.Map;
2021

2122
import org.springframework.boot.actuate.endpoint.EndpointId;
@@ -29,10 +30,12 @@
2930
*/
3031
class MappingWebEndpointPathMapper implements PathMapper {
3132

32-
private final Map<String, String> pathMapping;
33+
private final Map<EndpointId, String> pathMapping;
3334

3435
MappingWebEndpointPathMapper(Map<String, String> pathMapping) {
35-
this.pathMapping = pathMapping;
36+
this.pathMapping = new HashMap<>();
37+
pathMapping.forEach((id, path) -> this.pathMapping
38+
.put(EndpointId.fromPropertyValue(id), path));
3639
}
3740

3841
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapperTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,19 @@ public void userConfiguration() {
4545
assertThat(mapper.getRootPath(EndpointId.of("test"))).isEqualTo("custom");
4646
}
4747

48+
@Test
49+
public void mixedCaseDefaultConfiguration() {
50+
MappingWebEndpointPathMapper mapper = new MappingWebEndpointPathMapper(
51+
Collections.emptyMap());
52+
assertThat(mapper.getRootPath(EndpointId.of("testEndpoint")))
53+
.isEqualTo("testendpoint");
54+
}
55+
56+
@Test
57+
public void mixedCaseUserConfiguration() {
58+
MappingWebEndpointPathMapper mapper = new MappingWebEndpointPathMapper(
59+
Collections.singletonMap("test-endpoint", "custom"));
60+
assertThat(mapper.getRootPath(EndpointId.of("testEndpoint"))).isEqualTo("custom");
61+
}
62+
4863
}

0 commit comments

Comments
 (0)