You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2014/04/27 19:53:15 UTC

[jira] [Commented] (CONFIGURATION-566) BeanHelper.createBean() can't support Map<> bean property loading from file

    [ https://issues.apache.org/jira/browse/CONFIGURATION-566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13982407#comment-13982407 ] 

Oliver Heger commented on CONFIGURATION-566:
--------------------------------------------

When the {{isWriteable()}} check is removed the test case {{testInitBeanWithInvalidProperty}} fails. This test tries to set a value for a non-existing property. Obviously, {{setProperty()}} does not throw an exception in this case, but ignores the property it cannot resolve - this is in-line with the documentation of this method.

However, for Commons Configuration it is desired that an invalid or non-existing property causes an exception to be thrown. So the proposed fix cannot be applied.

I fear, it is not possible to implement a satisfying work-around in Configuration. This is really an issue for BeanUtils.

> BeanHelper.createBean() can't support Map<> bean property loading from file
> ---------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-566
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-566
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Type conversion
>    Affects Versions: 1.10
>            Reporter: Shen liang
>
> The issue is BeanUtils.setProperty() can support the java Map bean to set the (key, value) entry. But the BeahHelper.initProperty() add 1 more PropertyUtils.isWriteable() check. While this PropertyUtils.isWriteable() doesn't support java Map bean. 
> The check "PropertyUtils.isWriteable()" is quite redundant and unnecessary.
>   
> Is it better to remove the check "PropertyUtils.isWriteable()" since the BeanUtils.setProperty() has various ways to set the properties?
> {noformat}
> BeanHelper.createBean() 
>  -> DefaultBeanFactory.createBean()
>       -> DefaultBeanFactory.initBeanInstance()
>            -> BeanHelper.initBean()
>                 ->BeahHelper.initProperty()
>                    {
>                         if (!PropertyUtils.isWriteable(bean, propName))
>                         ...
>                         BeanUtils.setProperty(bean, propName, value);
>                    }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)