mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Don't limit collection sizes in property binding
Update PropertiesConfigurationFactory so that collections can grow beyond 256 items. Prior to this commit configuration property binding used the default `DataBinder.autoGrowNestedPaths` setting of 256. Fixes gh-6436
This commit is contained in:
parent
6a8620ac38
commit
8e22f47916
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -259,6 +259,7 @@ public class PropertiesConfigurationFactory<T>
|
||||
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);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -210,6 +210,19 @@ public class EnableConfigurationPropertiesTests {
|
||||
assertEquals(2, this.context.getBean(TestProperties.class).getList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollectionPropertiesBindingWithOver256Elements() {
|
||||
this.context.register(TestConfiguration.class);
|
||||
List<String> pairs = new ArrayList<String>();
|
||||
pairs.add("name:foo");
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
pairs.add("list[" + i + "]:" + i);
|
||||
}
|
||||
EnvironmentTestUtils.addEnvironment(this.context, pairs.toArray(new String[] {}));
|
||||
this.context.refresh();
|
||||
assertEquals(1000, this.context.getBean(TestProperties.class).getList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertiesBindingWithoutAnnotation() {
|
||||
this.context.register(InvalidConfiguration.class);
|
||||
|
Loading…
Reference in New Issue
Block a user