Commons BeanUtils
  1. Commons BeanUtils
  2. BEANUTILS-319

PropertyUtils.getPropertyType fails for DynaBeans contained within a normal bean

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.0-BETA
    • Fix Version/s: 1.8.0
    • Component/s: Bean / Property Utils
    • Labels:
      None

      Description

      public class OuterBean {
      private DynaBean inner;

      public DynaBean getInner()

      { return inner; }

      public void setInner(DynaBean inner)

      { this.inner = inner; }

      }

      I am unable to get the type of any of the DynaBean properties as nested properties of the outer bean. I can get them using the DynaBean directly, eg:

      PropertyUtils.getPropertyType(outer.getInner(), "foo") <- returns correct type
      PropertyUtils.getPropertyType(outer, "inner.foo") <- returns null

      1. patch.txt
        5 kB
        Erik Erskine
      2. InnerDynaBeanTestCase.java
        2 kB
        Erik Erskine

        Activity

        Hide
        Niall Pemberton added a comment -

        Erik, thanks for the patch - I committed a slightly modified version (using getProperty() to resolve the nested references):

        http://svn.apache.org/viewvc?view=rev&revision=687190

        Show
        Niall Pemberton added a comment - Erik, thanks for the patch - I committed a slightly modified version (using getProperty() to resolve the nested references): http://svn.apache.org/viewvc?view=rev&revision=687190
        Hide
        Erik Erskine added a comment -

        Here is a patch that I think fixes the problem.

        There is a loop in getPropertyDescriptor that resolves nested references to get to the "innnermost" bean. I have included this in each of the getPropertyType/isReadable/isWriteable methods (duplicated I'm afraid).

        Is this right? It seems to work and does not break the tests.

        Show
        Erik Erskine added a comment - Here is a patch that I think fixes the problem. There is a loop in getPropertyDescriptor that resolves nested references to get to the "innnermost" bean. I have included this in each of the getPropertyType/isReadable/isWriteable methods (duplicated I'm afraid). Is this right? It seems to work and does not break the tests.
        Hide
        Erik Erskine added a comment -

        isReadable/isWriteable methods are affected too (for the same reason) - I've updated the test accordingly

        Show
        Erik Erskine added a comment - isReadable/isWriteable methods are affected too (for the same reason) - I've updated the test accordingly
        Hide
        Erik Erskine added a comment -

        Here is a test case to illustrate the problem

        Show
        Erik Erskine added a comment - Here is a test case to illustrate the problem

          People

          • Assignee:
            Niall Pemberton
            Reporter:
            Erik Erskine
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development