Protect against null names when filter is applied more than once
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:24], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run
Details
Update `FilteredIterableConfigurationPropertiesSource` to fix a
regression caused by commit 8f14dca1
that occurs if the `filter()`
method is called on an already filtered source.
Fixes gh-46032
This commit is contained in:
parent
440ea79df1
commit
7b553d9093
|
@ -41,6 +41,9 @@ class FilteredIterableConfigurationPropertiesSource extends FilteredConfiguratio
|
||||||
this.filteredNames = new ConfigurationPropertyName[filterableNames.length];
|
this.filteredNames = new ConfigurationPropertyName[filterableNames.length];
|
||||||
this.numerOfFilteredNames = 0;
|
this.numerOfFilteredNames = 0;
|
||||||
for (ConfigurationPropertyName name : filterableNames) {
|
for (ConfigurationPropertyName name : filterableNames) {
|
||||||
|
if (name == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (filter.test(name)) {
|
if (filter.test(name)) {
|
||||||
this.filteredNames[this.numerOfFilteredNames++] = name;
|
this.filteredNames[this.numerOfFilteredNames++] = name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,24 @@ class FilteredIterableConfigurationPropertiesSourceTests extends FilteredConfigu
|
||||||
.containsExactly("a", "b", "c");
|
.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
|
@Test
|
||||||
void containsDescendantOfWhenSpringPropertySourceUsesContents() {
|
void containsDescendantOfWhenSpringPropertySourceUsesContents() {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue