Skip to content

Commit

Permalink
Merge branch '2.5.x' into 2.6.x
Browse files Browse the repository at this point in the history
Closes gh-30392
  • Loading branch information
wilkinsona committed Mar 23, 2022
2 parents 27ddcbd + 73d9e0e commit 9c128f1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Expand Up @@ -448,7 +448,7 @@ private boolean defaultElementEquals(Elements e1, Elements e2, int i) {
int i2 = 0;
while (i1 < l1) {
if (i2 >= l2) {
return false;
return remainderIsNotAlphaNumberic(e1, i, i1);
}
char ch1 = indexed1 ? e1.charAt(i, i1) : Character.toLowerCase(e1.charAt(i, i1));
char ch2 = indexed2 ? e2.charAt(i, i2) : Character.toLowerCase(e2.charAt(i, i2));
Expand All @@ -467,17 +467,23 @@ else if (ch1 != ch2) {
}
}
if (i2 < l2) {
if (indexed2) {
return remainderIsNotAlphaNumberic(e2, i, i2);
}
return true;
}

private boolean remainderIsNotAlphaNumberic(Elements elements, int element, int index) {
if (elements.getType(element).isIndexed()) {
return false;
}
int length = elements.getLength(element);
do {
char c = Character.toLowerCase(elements.charAt(element, index++));
if (ElementsParser.isAlphaNumeric(c)) {
return false;
}
do {
char ch2 = Character.toLowerCase(e2.charAt(i, i2++));
if (ElementsParser.isAlphaNumeric(ch2)) {
return false;
}
}
while (i2 < l2);
}
while (index < length);
return true;
}

Expand Down
Expand Up @@ -685,6 +685,15 @@ void equalsWhenNameStartsTheSameUsingDashedCompare() {
assertThat(n2).isNotEqualTo(n1);
}

@Test
void equalsWhenAdaptedNameMatchesDueToRemovalOfTrailingCharacters() {
// gh-30317
ConfigurationPropertyName name1 = ConfigurationPropertyName.of("example.demo");
ConfigurationPropertyName name2 = ConfigurationPropertyName.adapt("example.demo$$", '.');
assertThat(name1).isEqualTo(name2);
assertThat(name2).isEqualTo(name1);
}

@Test
void isValidWhenValidShouldReturnTrue() {
assertThat(ConfigurationPropertyName.isValid("")).isTrue();
Expand Down

0 comments on commit 9c128f1

Please sign in to comment.