Fix dashIgnoringElementEquals algorithm

Update `dashIgnoringElementEquals` so that trailing checks fail if
the last characters are not all `-`.

Fixes gh-16855
pull/16875/head
Phillip Webb 6 years ago
parent 963a544fb1
commit 10e67f8977

@ -397,7 +397,7 @@ public final class ConfigurationPropertyName
boolean indexed2 = e2.getType(i).isIndexed();
while (i2 < l2) {
char ch2 = e2.charAt(i, i2++);
if (indexed2 || ch2 == '-') {
if (indexed2 || ch2 != '-') {
return false;
}
}

@ -624,6 +624,16 @@ public class ConfigurationPropertyNameTests {
assertThat(n1).isNotEqualTo(n2);
}
@Test
public void equalsWhenNameStartsTheSameUsingDashedCompare() {
// gh-16855
ConfigurationPropertyName n1 = ConfigurationPropertyName
.of("management.metrics.web.server.auto-time-request");
ConfigurationPropertyName n2 = ConfigurationPropertyName
.of("management.metrics.web.server.auto-time-requests");
assertThat(n1).isNotEqualTo(n2);
}
@Test
public void isValidWhenValidShouldReturnTrue() {
assertThat(ConfigurationPropertyName.isValid("")).isTrue();

Loading…
Cancel
Save