Polish "Improve performance of CompositePropertySource#getPropertyNames"

See gh-27236
This commit is contained in:
Stephane Nicoll
2023-08-26 17:45:25 +02:00
parent b67a381fbe
commit 5c691960a2
3 changed files with 24 additions and 10 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.core.env;
import java.util.Collections;
import java.util.Map;
import org.junit.jupiter.api.Test;
@@ -46,4 +47,13 @@ class CompositePropertySourceTests {
assertThat(((i1 < i2) && (i2 < i3))).as("Bad order: " + s).isTrue();
}
@Test
void getPropertyNamesRemovesDuplicates() {
CompositePropertySource composite = new CompositePropertySource("c");
composite.addPropertySource(new MapPropertySource("p1", Map.of("p1.property", "value")));
composite.addPropertySource(new MapPropertySource("p2",
Map.of("p2.property1", "value", "p1.property", "value", "p2.property2", "value")));
assertThat(composite.getPropertyNames()).containsOnly("p1.property", "p2.property1", "p2.property2");
}
}