commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (Updated) (JIRA)" <>
Subject [jira] [Updated] (SANDBOX-397) [BeanUtils2] Replace NullPointerExceptions been thrown in DefaultBeanAccessor with NoSuchMethodEceptions
Date Sat, 25 Feb 2012 15:57:48 GMT


Benedikt Ritter updated SANDBOX-397:

    Attachment: SANDBOX-397_SRP.txt

I have created another patch, that builds upon the first one. I think it is not a responsibility
of a {{DefaultBeanAccessor}} to figure out, whether or not properties are available or not.
So the private methods from the first patch are a violation of SRP [1].

For this reason I created a new class, that is reponsible for handling properties of a class:
{{Properties<B>}}. I think this is a nice and clean solution to the SRP violation. However
the patch is incomplete, because several unit tests fail (for details see below). I uploaded
the patch anyway, because I want to know, what you think about the hole idea, before I start
to fix the issues raised by the new class.

The reason for the failing tests is, that {{DefaultBeanAccessor}} creates a {{Properties}}
object in its constructor using the bean object passed in. A {{DefaultBeanAccessor}} can be
created in several ways:
* {{BeanUtils.on(B bean)}}
* {{ArgumentsAccessor.with(...)}}

If in the latter case, a method is invoked that returns void, instantiation of {{DefaultBeanAccessor}}
will fail, because the constructor tries to call {{getClass()}} on {{null}}.

I think this is not a problem of the newly invented {{Properties<B>}} class, but of
{{ArgumentAccessor.with(...)}}. In other words, this was broken before but we had no tests
for this case.

A solution could be to write a Special Case [2] implementation of {{BeanAccessor}} for this
case ({{NullBeanAccessor}}) that will be returned by {{ArgumentsAccessor.with(...)}} if a
method returns void.

What do you think?

All the best,

> [BeanUtils2] Replace NullPointerExceptions been thrown in DefaultBeanAccessor with NoSuchMethodEceptions
> --------------------------------------------------------------------------------------------------------
>                 Key: SANDBOX-397
>                 URL:
>             Project: Commons Sandbox
>          Issue Type: Task
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>         Attachments: SANDBOX-397.txt, SANDBOX-397_SRP.txt
> At the moment, methods in {{DefaultBeanAccessor}} throw a {{NullPointerException}}, if
no {{PropertyDescriptor}} for a given property name can be retrieved. As discussed on the
ML (see this behavior should be changed to throwing

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message