commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 18835] - BeanComparator compare method throws ClassCastException regardless of underlying exception
Date Wed, 09 Apr 2003 01:10:27 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18835>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18835

BeanComparator compare method throws ClassCastException regardless of underlying exception





------- Additional Comments From tobrien@discursive.com  2003-04-09 01:10 -------
I just submitted two patches, that propose a solution to this.  I was tempted 
to use exception chaining, but our committment to maintain 1.2 compatibility 
isn't about to change.

The patches submitted:

1. Throw a RuntimeException with a descriptive message.  Instead of one 
try/catch block, the compare method has 3, and each try/catch 
literally "rethrows" an exception as a RuntimeException adding the original 
exception's message to the message of the newly created RuntimeException.  It 
would be preferable to use Exception chaining in this situation, but this would 
require JDK 1.4.

2. The patches also provide support for the comparison of beans which may not 
contain the specified property.  At first glance this usage seems odd, but 
imagine trying to sort a Collection of interfaces by a property which may not 
be shared by all objects in that collection.  Adding a property to 
BeanComparator "failOnMissing" allows one to treat missing properties as null.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message