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

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        48d 12h 24m 1 Niall Pemberton 19/Aug/08 23:54
        Resolved Resolved Closed Closed
        340d 8h 10m 1 Henri Yandell 26/Jul/09 08:04
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Niall Pemberton made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.8.0 [ 12311949 ]
        Assignee Niall Pemberton [ niallp ]
        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
        Erik Erskine made changes -
        Attachment patch.txt [ 12385130 ]
        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.
        Erik Erskine made changes -
        Attachment InnerDynaBeanTestCase.java [ 12385106 ]
        Erik Erskine made changes -
        Attachment InnerDynaBeanTestCase.java [ 12385128 ]
        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
        Erik Erskine made changes -
        Field Original Value New Value
        Attachment InnerDynaBeanTestCase.java [ 12385106 ]
        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
        Erik Erskine created issue -

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development