diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java index 6ce1bf1c7e..cb41a2268b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java @@ -263,6 +263,7 @@ public class PropertiesConfigurationFactory if (this.conversionService != null) { dataBinder.setConversionService(this.conversionService); } + dataBinder.setAutoGrowCollectionLimit(Integer.MAX_VALUE); dataBinder.setIgnoreNestedProperties(this.ignoreNestedProperties); dataBinder.setIgnoreInvalidFields(this.ignoreInvalidFields); dataBinder.setIgnoreUnknownFields(this.ignoreUnknownFields); diff --git a/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java b/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java index ba50fcd5e1..86b5d42bf4 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java @@ -225,6 +225,20 @@ public class EnableConfigurationPropertiesTests { assertThat(this.context.getBean(TestProperties.class).getList()).hasSize(2); } + @Test + public void testCollectionPropertiesBindingWithOver256Elements() { + this.context.register(TestConfiguration.class); + List pairs = new ArrayList(); + pairs.add("name:foo"); + for (int i = 0; i < 1000; i++) { + pairs.add("list[" + i + "]:" + i); + } + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, + pairs.toArray(new String[] {})); + this.context.refresh(); + assertThat(this.context.getBean(TestProperties.class).getList()).hasSize(1000); + } + @Test public void testPropertiesBindingWithoutAnnotation() { this.context.register(InvalidConfiguration.class);