Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-14888

Detect invalid configuration for autoGrowCollectionLimit on DataBinder

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.2.8, 4.3.4
    • Fix Version/s: 4.3.5, 5.0 M4
    • Component/s: Core
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              kazuki43zoo Kazuki Shimizu
              Last updater:
              Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 6 weeks, 6 days ago