directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r567175 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java
Date Fri, 17 Aug 2007 23:34:19 GMT
Author: akarasulu
Date: Fri Aug 17 16:34:18 2007
New Revision: 567175

URL: http://svn.apache.org/viewvc?view=rev&rev=567175
Log:
fix for DIRSERVER-928: ComparableComparator in shared yeild incorrect results when two objects
compared are not

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java?view=diff&rev=567175&r1=567174&r2=567175
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java
Fri Aug 17 16:34:18 2007
@@ -30,6 +30,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
+@SuppressWarnings("unchecked")
 public class ComparableComparator implements Comparator, Serializable
 {
     static final long serialVersionUID = -5295278271807198471L;
@@ -57,6 +58,11 @@
             return -( ( Comparable ) o2 ).compareTo( o1 );
         }
 
-        return o1.hashCode() - o2.hashCode();
+        // before https://issues.apache.org/jira/browse/DIRSERVER-928 it was
+        // return o1.hashCode() - o2.hashCode();
+        
+        // now we will blow a stack trace if none of the objects are Comparable
+        throw new IllegalArgumentException( "None of the arguments are Comparable objects:\n"

+            + "\targ1 = " + o1 + "\n\targ2 = " + o2 );
     }
 }



Mime
View raw message