[ 
https://issues.apache.org/jira/browse/SANDBOX-371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Benedikt Ritter updated SANDBOX-371:
------------------------------------

    Attachment: SANDBOX-371.txt

I've created a patch. Summary:
* Added the above mentioned code to DefaultBeanAccessor.getProperty(String name)
* Extended GetPropertyTestCase
* Fixed wrong Annotion on GetPropertyTestCase, that caused the test to fail
* Changed assert messages on GetPropertyTestCase.getSimpleProperty()
                
> [BeanUtils2] Make sure that a property is readable in 
> DefaultBeanAccessor.getProperty( String name )
> ----------------------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-371
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-371
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>         Attachments: SANDBOX-371.txt
>
>
> Problem: The following statement in line 50 in DefaultBeanAccessor may cause 
> a NullPointerException, because getReadMethod() will return null, if no 
> getter for the property is present: 
> {code:java}Object newBean = propertyDescriptor.getReadMethod().invoke( bean 
> ); {code}
> Solution: throw a NoSuchMethodException, if the property is write only.
> {code:java}
> if ( propertyDescriptor.getReadMethod() == null )
> {
>     throw new NoSuchMethodException( String.format( "Bean of type %s does not 
> provide a getter for property '%s'!",
>                                                  bean.getClass().getName(), 
> name ) );
> }{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to