Skip to content

Commit

Permalink
Bug Fix - ConfigurationPropertyName#equals is not symmetric with trai…
Browse files Browse the repository at this point in the history
…ling dashes in an element. See also: spring-projectsgh-30393
  • Loading branch information
eydunn committed Mar 28, 2023
1 parent be014ca commit cf70171
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private boolean dashIgnoringElementEquals(Elements e1, Elements e2, int i) {
int i2 = 0;
while (i1 < l1) {
if (i2 >= l2) {
return false;
return remainderIsNotAlphanumeric(e1, i, i1);
}
char ch1 = e1.charAt(i, i1);
char ch2 = e2.charAt(i, i2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,14 @@ void equalsWhenAdaptedNameMatchesDueToRemovalOfTrailingCharacters() {
assertThat(name2).isEqualTo(name1);
}

@Test
void equalsSymmetricWhenNameMatchesDueToRemovalOfTrailingDashes() {
ConfigurationPropertyName n1 = ConfigurationPropertyName.of("foobar");
ConfigurationPropertyName n2 = ConfigurationPropertyName.of("foobar--");
assertThat(n1).isEqualTo(n2);
assertThat(n2).isEqualTo(n1);
}

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

0 comments on commit cf70171

Please sign in to comment.