Fix ConfigurationPropertyName.equals for uppercase

Commit 7f35f8a9 for gh-14665 was unfortunately incomplete as it didn't
account for uppercase values. The run-off while loop should have used
`Character.toLowerCase` in the same way as the main while loop.

Fixes gh-15152
This commit is contained in:
Phillip Webb
2018-11-15 13:48:20 -08:00
parent dbf09de203
commit bab111b37e
2 changed files with 21 additions and 1 deletions

View File

@@ -347,7 +347,7 @@ public final class ConfigurationPropertyName
}
}
while (i2 < l2) {
char ch2 = e2.charAt(i, i2++);
char ch2 = Character.toLowerCase(e2.charAt(i, i2++));
if (indexed2 || ElementsParser.isAlphaNumeric(ch2)) {
return false;
}

View File

@@ -609,6 +609,26 @@ public class ConfigurationPropertyNameTests {
assertThat(n1).isNotEqualTo(n2);
}
@Test
public void equalsWhenStartsWithOfAdaptedName() {
// gh-15152
ConfigurationPropertyName n1 = ConfigurationPropertyName
.adapt("example.mymap.ALPHA", '.');
ConfigurationPropertyName n2 = ConfigurationPropertyName
.adapt("example.mymap.ALPHA_BRAVO", '.');
assertThat(n1).isNotEqualTo(n2);
}
@Test
public void equalsWhenStartsWithOfAdaptedNameOfIllegalChars() {
// gh-15152
ConfigurationPropertyName n1 = ConfigurationPropertyName
.adapt("example.mymap.ALPH!", '.');
ConfigurationPropertyName n2 = ConfigurationPropertyName
.adapt("example.mymap.ALPHA!BRAVO", '.');
assertThat(n1).isNotEqualTo(n2);
}
@Test
public void isValidWhenValidShouldReturnTrue() {
assertThat(ConfigurationPropertyName.isValid("")).isTrue();