Merge branch 'main' into 4.0.x

This commit is contained in:
Phillip Webb
2025-06-19 08:59:29 -07:00
2 changed files with 21 additions and 0 deletions
@@ -41,6 +41,9 @@ class FilteredIterableConfigurationPropertiesSource extends FilteredConfiguratio
this.filteredNames = new ConfigurationPropertyName[filterableNames.length];
this.numerOfFilteredNames = 0;
for (ConfigurationPropertyName name : filterableNames) {
if (name == null) {
break;
}
if (filter.test(name)) {
this.filteredNames[this.numerOfFilteredNames++] = name;
}
@@ -74,6 +74,24 @@ class FilteredIterableConfigurationPropertiesSourceTests extends FilteredConfigu
.containsExactly("a", "b", "c");
}
@Test
void iteratorWhenSpringPropertySourceAndAnotherFilterFiltersNames() {
IterableConfigurationPropertySource testSource = (IterableConfigurationPropertySource) createTestSource();
Map<String, Object> map = new LinkedHashMap<>();
for (ConfigurationPropertyName name : testSource) {
map.put(name.toString(), testSource.getConfigurationProperty(name).getValue());
}
PropertySource<?> propertySource = new OriginTrackedMapPropertySource("test", map, true);
SpringConfigurationPropertySource source = SpringConfigurationPropertySource.from(propertySource);
IterableConfigurationPropertySource filtered = (IterableConfigurationPropertySource) source
.filter(this::noBrackets);
IterableConfigurationPropertySource secondFiltered = filtered.filter((name) -> !name.toString().contains("c"));
assertThat(Extractors.byName("filteredNames").apply(filtered)).isNotNull();
assertThat(secondFiltered.iterator()).toIterable()
.extracting(ConfigurationPropertyName::toString)
.containsExactly("a", "b");
}
@Test
void containsDescendantOfWhenSpringPropertySourceUsesContents() {
Map<String, Object> map = new LinkedHashMap<>();