Merge branch '3.4.x'
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

Closes gh-46040
This commit is contained in:
Phillip Webb 2025-06-19 15:14:35 -07:00
commit 18e5e0647d
2 changed files with 27 additions and 0 deletions

View File

@ -576,6 +576,7 @@ public class Binder {
if (source == null) {
return supplier.get();
}
ConfigurationPropertySource previous = this.source.get(0);
this.source.set(0, source);
this.sourcePushCount++;
try {
@ -583,6 +584,7 @@ public class Binder {
}
finally {
this.sourcePushCount--;
this.source.set(0, previous);
}
}

View File

@ -143,6 +143,21 @@ class CollectionBinderTests {
});
}
@Test
void bindToNestedCollectionWhenNonKnownIndexed() {
// gh-46039
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo[0].items[0]", "a");
source.put("foo[0].items[1]", "b");
source.put("foo[0].string", "test");
this.sources.add(source);
List<ExampleCollectionBean> list = this.binder.bind("foo", Bindable.listOf(ExampleCollectionBean.class)).get();
assertThat(list).hasSize(1);
ExampleCollectionBean bean = list.get(0);
assertThat(bean.getItems()).containsExactly("a", "b", "d");
assertThat(bean.getString()).isEqualTo("test");
}
@Test
void bindToNonScalarCollectionWhenNonSequentialShouldThrowException() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
@ -456,6 +471,8 @@ class CollectionBinderTests {
private Set<String> itemsSet = new LinkedHashSet<>();
private String string;
List<String> getItems() {
return this.items;
}
@ -472,6 +489,14 @@ class CollectionBinderTests {
this.itemsSet = itemsSet;
}
String getString() {
return this.string;
}
void setString(String string) {
this.string = string;
}
}
static class ExampleCustomNoDefaultConstructorBean {