Skip to content

Detect invalid configuration for autoGrowCollectionLimit on DataBinder [SPR-14888] #19454

@spring-projects-issues

Description

@spring-projects-issues

Kazuki Shimizu opened SPR-14888 and commented

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:

Referenced from: pull request #1233

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions