[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
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