Fix dashIgnoringElementEquals algorithm
Update `dashIgnoringElementEquals` so that trailing checks fail if the last characters are not all `-`. Fixes gh-16855
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user