Skip to content

Cannot customize autoGrowCollectionLimit on @InitBinder method when set custom MessageCodesResolver to Spring MVC [SPR-15009] #19576

@spring-projects-issues

Description

@spring-projects-issues

Kazuki Shimizu opened SPR-15009 and commented

In current implementation, We cannot customize the autoGrowCollectionLimit of DataBinder when set a custom MessageCodesResolver to the Spring MVC using WebMvcConfigurerAdapter or <mvc:annotation-driven>.

Because it initialize a BindingResult on the DataBinder as follow:

public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) {
    getInternalBindingResult().setMessageCodesResolver(messageCodesResolver);
}

I think it should be changed to same logic with ConversionService as follow:

public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) {
    Assert.state(this.messageCodesResolver == null, "DataBinder is already initialized with MessageCodesResolver");
    this.messageCodesResolver = messageCodesResolver;
    if (this.bindingResult != null && messageCodesResolver != null) {
        this.bindingResult.setMessageCodesResolver(messageCodesResolver);
    }
}

What do you think ?
I will submit a PR at the later.


Affects: 4.3.4

Issue Links:

Referenced from: pull request #1266, and commits 307e37a, 8d55c7d, 58eccfe, 361ab6b, 9f22928

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