Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-175

[beanutils] Handling of exceptions thrown during BeanUtils.populate

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • 2.0.0
    • Bean / Property Utils
    • None
    • Operating System: All
      Platform: All

    • 20549

    Description

      I run into a problem when using Struts to populate request parameters to a
      form's nested property when either the conversion from String to int (for
      example) fails or when the set method in the nested bean throws an exception
      such as IllegalArgumentException.

      I propose that we add a property to BeanUtilsBean for a new interface called
      something like PopulateExceptionHandler which will have a method something like
      void execute(Exception exception, Object bean, String propertyPath, Object
      value)

      Then, within BeanUtilsBean.populate, within the loop, it would catch any
      exception, and call the populateExceptionHandler's execute method with it
      (unwrapping InvocationTargetException's). The default handler would just
      rethrow it (or we could have no default handler, and if no handler is present,
      the BeanUtils method rethrows it).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ericpabst@discoverfinancial.com Eric Pabst
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: