Migrate legacy endpoint that have a dash in their id
See gh-21615
This commit is contained in:
committed by
Stephane Nicoll
parent
8962d6ca21
commit
0f9f10f97e
@@ -131,7 +131,7 @@ public final class EndpointId {
|
||||
|
||||
private static String migrateLegacyId(Environment environment, String value) {
|
||||
if (environment.getProperty(MIGRATE_LEGACY_NAMES_PROPERTY, Boolean.class, false)) {
|
||||
return value.replace(".", "");
|
||||
return value.replaceAll("[-.]+", "");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,16 @@ class EndpointIdTests {
|
||||
assertThat(output).doesNotContain("contains invalid characters");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenMigratingLegacyNameRemovesHyphens(CapturedOutput output) {
|
||||
EndpointId.resetLoggedWarnings();
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("management.endpoints.migrate-legacy-ids", "true");
|
||||
EndpointId endpointId = EndpointId.of(environment, "foo-bar");
|
||||
assertThat(endpointId.toString()).isEqualTo("foobar");
|
||||
assertThat(output).doesNotContain("contains invalid characters");
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsAndHashCode() {
|
||||
EndpointId one = EndpointId.of("foobar1");
|
||||
|
||||
Reference in New Issue
Block a user