You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Matthew Toso (JIRA)" <ji...@apache.org> on 2011/03/11 17:38:01 UTC
[jira] Created: (BEANUTILS-390) BeanComparator throws exception for
null property values
BeanComparator throws exception for null property values
--------------------------------------------------------
Key: BEANUTILS-390
URL: https://issues.apache.org/jira/browse/BEANUTILS-390
Project: Commons BeanUtils
Issue Type: Improvement
Components: Bean-Collections
Affects Versions: 1.8.3
Reporter: Matthew Toso
Priority: Minor
When using a BeanComparator to sort on a bean property that may contain null values, an exception is thrown. By default, the BeanComparator uses a ComparableComparator internally. ComparableComparator in turn throws a NullPointerException when it attempts to compare to a null value. My proposed solution is extending BeanComparator with a new class, NullSafeBeanComparator, that incorporates logic from NullComparator. I have a working example and will attach it.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Resolved: (BEANUTILS-390) BeanComparator throws exception
for null property values
Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Niall Pemberton resolved BEANUTILS-390.
---------------------------------------
Resolution: Won't Fix
There is no need for NullSafeBeanComparator - you can construct a BeanComparator with any Comparator implementation, so you just need to do that with a null-safe flavour. As you point out, the NullPointerException is in ComparableComparator - which isn't even part of BeanUtils
> BeanComparator throws exception for null property values
> --------------------------------------------------------
>
> Key: BEANUTILS-390
> URL: https://issues.apache.org/jira/browse/BEANUTILS-390
> Project: Commons BeanUtils
> Issue Type: Improvement
> Components: Bean-Collections
> Affects Versions: 1.8.3
> Reporter: Matthew Toso
> Priority: Minor
> Attachments: NullSafeBeanComparator.java
>
>
> When using a BeanComparator to sort on a bean property that may contain null values, an exception is thrown. By default, the BeanComparator uses a ComparableComparator internally. ComparableComparator in turn throws a NullPointerException when it attempts to compare to a null value. My proposed solution is extending BeanComparator with a new class, NullSafeBeanComparator, that incorporates logic from NullComparator. I have a working example and will attach it.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (BEANUTILS-390) BeanComparator throws exception for
null property values
Posted by "Matthew Toso (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/BEANUTILS-390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthew Toso updated BEANUTILS-390:
-----------------------------------
Attachment: NullSafeBeanComparator.java
This is a working example of the NullSafeBeanComparator.
> BeanComparator throws exception for null property values
> --------------------------------------------------------
>
> Key: BEANUTILS-390
> URL: https://issues.apache.org/jira/browse/BEANUTILS-390
> Project: Commons BeanUtils
> Issue Type: Improvement
> Components: Bean-Collections
> Affects Versions: 1.8.3
> Reporter: Matthew Toso
> Priority: Minor
> Attachments: NullSafeBeanComparator.java
>
>
> When using a BeanComparator to sort on a bean property that may contain null values, an exception is thrown. By default, the BeanComparator uses a ComparableComparator internally. ComparableComparator in turn throws a NullPointerException when it attempts to compare to a null value. My proposed solution is extending BeanComparator with a new class, NullSafeBeanComparator, that incorporates logic from NullComparator. I have a working example and will attach it.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira