In current implementation, the DataBinder can't detect invalid configuration for autoGrowCollectionLimit as follow:
DataBinder binder = new DataBinder(new BeanWithIntegerList());
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
binder.setAutoGrowCollectionLimit(257); // Invalid configuration -> But no error
In this case, we should be call the setAutoGrowCollectionLimit method before calling the registerCustomEditor method. I think it would be better to raise an exception as follow:
public void setAutoGrowCollectionLimit(int autoGrowCollectionLimit) {
Assert.state(this.bindingResult == null,
"DataBinder is already initialized - call setAutoGrowCollectionLimit before other configuration methods");
this.autoGrowCollectionLimit = autoGrowCollectionLimit;
}
What do you think ?
I will submit a PR at the later.
Affects: 4.2.8, 4.3.4
Issue Links:
#19576 Cannot customize autoGrowCollectionLimit on @InitBinder method when set custom MessageCodesResolver to Spring MVC
Kazuki Shimizu opened SPR-14888 and commented
In current implementation, the
DataBinder
can't detect invalid configuration forautoGrowCollectionLimit
as follow:In this case, we should be call the setAutoGrowCollectionLimit method before calling the registerCustomEditor method. I think it would be better to raise an exception as follow:
What do you think ?
I will submit a PR at the later.
Affects: 4.2.8, 4.3.4
Issue Links:
@InitBinder
method when set custom MessageCodesResolver to Spring MVCReferenced from: pull request #1233
The text was updated successfully, but these errors were encountered: