Commit 10e67f89 authored by Phillip Webb's avatar Phillip Webb

Fix dashIgnoringElementEquals algorithm

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

Fixes gh-16855
parent 963a544f
...@@ -397,7 +397,7 @@ public final class ConfigurationPropertyName ...@@ -397,7 +397,7 @@ public final class ConfigurationPropertyName
boolean indexed2 = e2.getType(i).isIndexed(); boolean indexed2 = e2.getType(i).isIndexed();
while (i2 < l2) { while (i2 < l2) {
char ch2 = e2.charAt(i, i2++); char ch2 = e2.charAt(i, i2++);
if (indexed2 || ch2 == '-') { if (indexed2 || ch2 != '-') {
return false; return false;
} }
} }
......
...@@ -624,6 +624,16 @@ public class ConfigurationPropertyNameTests { ...@@ -624,6 +624,16 @@ public class ConfigurationPropertyNameTests {
assertThat(n1).isNotEqualTo(n2); 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 @Test
public void isValidWhenValidShouldReturnTrue() { public void isValidWhenValidShouldReturnTrue() {
assertThat(ConfigurationPropertyName.isValid("")).isTrue(); assertThat(ConfigurationPropertyName.isValid("")).isTrue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment