commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <>
Subject [jira] Commented: (BEANUTILS-268) doesn't can't handle null values returned by bean properties
Date Mon, 22 Jan 2007 21:16:30 GMT


Niall Pemberton commented on BEANUTILS-268:

I don't believe this is an issue for BeanComparator - since all it does is delegate comparing
the properties to the Comparator passed in its constructor (or ComparableComparator if none
supplied). As the BeanComparator JavaDocs state:

    "If you are comparing two beans based on a property that could contain "null" values,
a suitable Comparator or ComparatorChain should be supplied in the constructor."

IMO we should close this as an "Invalid" issue.


> doesn't can't handle null values returned by bean properties
> -------------------------------------------------------------------------------------
>                 Key: BEANUTILS-268
>                 URL:
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean-Collections
>    Affects Versions: 1.7.0
>            Reporter: Jacob Kjome
> I've got a bean that has properties that will, at times, return null values.  BeanComparator
appears to fail with a NullPointerException.  It's difficult to tell exactly where because
the exception thrown is a ClassCastException with a message of e.toString(), so all I know
is that a NullPointerException happened, not where it happened.
> I suspect that the exception happens inside the compare(Object, Object) method with the
> Object value1 = PropertyUtils.getProperty( o1, property );
> Looking into PropertyUtils, and following the path, it seems like the problematic code
is in...
> PropertyUtilsBean.getNestedProperty(Object, String)
> That code is rather involved.  If I get around to performing a minimal testcase, I'll
see if I can narrow down the exception to a particular piece of code.  In any case, there's
no reason why a bean shouldn't be allowed to return null for a given property.
> My workaround is to add methods for respective properties that are guaranteed to not
return null.  For instance, if I have a getter called getMyValue(), I create a corresponding
method called getMyValueNotNul().  I have to take care with the value it returns, though.
 The position in a sort for a null value would be different than a literal empty String. 
So, depending on the Object type, I have to make up values which will either come before all
other non-null values or after all other non-null values (I don't recall what the natural
order of null values are; whether they come first or last.  I know when ordering on a SQLcolumn,
null values show up last.  Hopefully that behavior is consistent here, but that's beside the
point here).
> I hope this can be fixed before 1.8.0 is released!
> Jake

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message