diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index e7b9eae2e8..a1a3d6b7b1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -406,7 +406,7 @@ public final class ConfigurationPropertyName implements Comparable= l2) { - return false; + return remainderIsNotAlphanumeric(e1, i, i1); } char ch1 = e1.charAt(i, i1); char ch2 = e2.charAt(i, i2); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java index e0afc334b4..2cf37b77a7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java @@ -702,6 +702,14 @@ class ConfigurationPropertyNameTests { 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();