Skip to content

Commit d8b9685

Browse files
committed
Support '.' in endpoint names
Update the `EndpointId` constraints to allow '.' in names. Closes gh-14773
1 parent 99a45bd commit d8b9685

File tree

2 files changed

+14
-6
lines changed
  • spring-boot-project/spring-boot-actuator/src

2 files changed

+14
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222
import org.springframework.util.Assert;
2323

2424
/**
25-
* An identifier for an actuator endpoint. Endpoint IDs may contain only letters and
26-
* numbers and must begin with a lower-case letter. Case is ignored when comparing
27-
* endpoint IDs.
25+
* An identifier for an actuator endpoint. Endpoint IDs may contain only letters, numbers
26+
* and {@code '.'}. They must begin with a lower-case letter. Case is ignored when
27+
* comparing endpoint IDs.
2828
*
2929
* @author Phillip Webb
3030
* @since 2.0.6
3131
*/
3232
public final class EndpointId {
3333

34-
private static final Pattern ALPHA_NUMERIC = Pattern.compile("[a-zA-Z0-9]+");
34+
private static final Pattern VALID_CHARS = Pattern.compile("[a-zA-Z0-9\\.]+");
3535

3636
private final String value;
3737

3838
private final String lowerCaseValue;
3939

4040
private EndpointId(String value) {
4141
Assert.hasText(value, "Value must not be empty");
42-
Assert.isTrue(ALPHA_NUMERIC.matcher(value).matches(),
43-
"Value must be alpha-numeric");
42+
Assert.isTrue(VALID_CHARS.matcher(value).matches(),
43+
"Value must be alpha-numeric or '.'");
4444
Assert.isTrue(!Character.isDigit(value.charAt(0)),
4545
"Value must not start with a number");
4646
Assert.isTrue(!Character.isUpperCase(value.charAt(0)),

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/EndpointIdTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ public void ofWhenStartsWithUppercaseLetterThrowsException() {
7474
EndpointId.of("Foo");
7575
}
7676

77+
@Test
78+
public void ofWhenContainsDotIsValid() {
79+
// Ideally we wouldn't support this but there are existing endpoints using the
80+
// pattern. See gh-14773
81+
EndpointId endpointId = EndpointId.of("foo.bar");
82+
assertThat(endpointId.toString()).isEqualTo("foo.bar");
83+
}
84+
7785
@Test
7886
public void equalsAndHashCode() {
7987
EndpointId one = EndpointId.of("foobar");

0 commit comments

Comments
 (0)