Skip to content

Commit 9ad1934

Browse files
committed
Merge pull request #16671 from izeye
* pr/16671: Polish defaultElementEquals Polish dashIgnoringElementEquals() Closes gh-16671
2 parents ec72d28 + 763d18c commit 9ad1934

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,17 @@ else if (ch1 != ch2) {
360360
i2++;
361361
}
362362
}
363-
while (i2 < l2) {
364-
char ch2 = Character.toLowerCase(e2.charAt(i, i2++));
365-
if (indexed2 || ElementsParser.isAlphaNumeric(ch2)) {
363+
if (i2 < l2) {
364+
if (indexed2) {
366365
return false;
367366
}
367+
do {
368+
char ch2 = Character.toLowerCase(e2.charAt(i, i2++));
369+
if (ElementsParser.isAlphaNumeric(ch2)) {
370+
return false;
371+
}
372+
}
373+
while (i2 < l2);
368374
}
369375
return true;
370376
}
@@ -394,12 +400,17 @@ else if (ch1 != ch2) {
394400
i2++;
395401
}
396402
}
397-
boolean indexed2 = e2.getType(i).isIndexed();
398-
while (i2 < l2) {
399-
char ch2 = e2.charAt(i, i2++);
400-
if (indexed2 || ch2 != '-') {
403+
if (i2 < l2) {
404+
if (e2.getType(i).isIndexed()) {
401405
return false;
402406
}
407+
do {
408+
char ch2 = e2.charAt(i, i2++);
409+
if (ch2 != '-') {
410+
return false;
411+
}
412+
}
413+
while (i2 < l2);
403414
}
404415
return true;
405416
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ public void equalsWhenNameStartsTheSameUsingDashedCompare() {
632632
ConfigurationPropertyName n2 = ConfigurationPropertyName
633633
.of("management.metrics.web.server.auto-time-requests");
634634
assertThat(n1).isNotEqualTo(n2);
635+
assertThat(n2).isNotEqualTo(n1);
635636
}
636637

637638
@Test

0 commit comments

Comments
 (0)