You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Niall Pemberton (JIRA)" <ji...@apache.org> on 2009/10/05 15:35:31 UTC

[jira] Commented: (BEANUTILS-357) PropertyUtilsTestCase.testGetReadMethod* fail for abstract properties.

    [ https://issues.apache.org/jira/browse/BEANUTILS-357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12762174#action_12762174 ] 

Niall Pemberton commented on BEANUTILS-357:
-------------------------------------------

Richard,

I'm not sure about the inner class example you provide especially when you say:

    * "...did not include my equivalent of 'TestBean.InnerClass' because, I believe, PropertyUtils returned AbstractTestBean$InnerClass instead of TestBean$InnerClass."

In your example TestBean$InnerClass and AbstractTestBean$InnerClass are one and the same thing -  InnerClass is declared in AbstractTestBean - TestBean inherits it, but the class is always AbstractTestBean$InnerClass. But this seems to me to be barking up the wrong tree because this bug was about the *read method* returning the wrong declaring class. When I tried your example I found that in the declaring class of the read method for "innerClassProperty" to be correct - i.e. the concrete sub-class (see the test case for the bug[1]).

Anyway I did some further investigation into the original issue and found that making the changes you originally described only caused the tests to fail on one particular method - that was the "booleanSecond" property which has a "isBooleanSecond" getter method. Changing the getter method name to "getBooleanSecond" resulted in the issue disappearing.

I have added a new test case for this bug here:

[1]  http://svn.apache.org/repos/asf/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira357TestCase.java

Anyway all this is interesting, but its not BeanUtils that is providing the property descriptors and their get methods - BeanUtils uses java's Introspector[2] and BeanInfo[3] classes to get the property descriptors, so it looks like a bug in Java to me:

{code}
    BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
    PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
{code}

[2] http://java.sun.com/j2se/1.5.0/docs/api/java/beans/Introspector.html
[3] http://java.sun.com/j2se/1.5.0/docs/api/java/beans/BeanInfo.html


> PropertyUtilsTestCase.testGetReadMethod* fail for abstract properties.
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-357
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-357
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>         Environment: Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
> Linux 2.6.24-22-generic #1 SMP Mon Nov 24 18:32:42 UTC 2008 i686 GNU/Linux
>            Reporter: Richard O'Sullivan
>         Attachments: AbstractTestBean.java, BEANUTILS-357-AbstractTestBean.patch
>
>
> Create org.apache.commons.beanutils.AbstractTestBean with abstract methods for properties in TestBean and change TestBean to extend AbstractTestBean. Run PropertyUtilsTestCase, the testGetReadMethod* methods fail because "Correct declaring class for X expected:<...Abstract...> but was:<......>".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.