UUID compareTo and hashCode
---------------------------
Key: JCR-687
URL: http://issues.apache.org/jira/browse/JCR-687
Project: Jackrabbit
Issue Type: Bug
Components: core
Reporter: Thomas Mueller
Priority: Minor
The current UUID.compareTo implementation is not correct. Usually, 'equals' is used so this
is not a big problem, but I need to create an ordered list of UUIDs and for this I need compareTo.
The current implementation is based on subtraction, but this doesn't always work. Example:
//long a = 10, b = 20, c = 0;
long a = Long.MAX_VALUE, b = Long.MIN_VALUE, c = 0;
System.out.println((a - b) < 0 ? "a < b" : "a >= b");
System.out.println((c - a) < 0 ? "c < a" : "c >= a");
System.out.println((b - c) < 0 ? "b < c" : "b >= c");
The hashCode implementation is OK, but the multiplication is not required.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|