[JAVA-609] ObjectId equals(...) broken Created: 24/Jul/12 Updated: 31/Mar/15 Resolved: 25/Jun/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.7.3 |
| Fix Version/s: | 3.0.0 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Oliver Gierke | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
ObjectId's equals(...) method is implemented invalidly. equals(...) methods need to be symmetrical, which means if A.equals(B) is true, B.equals(A) needs to be true as well. This is not the case as the implementation massages String values into ObjectId instances and thus surprisingly the following code succeeds:
This breaks once you test for symmetry:
|
| Comments |
| Comment by Jeffrey Yemin [ 31/Mar/15 ] |
|
Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released. |
| Comment by auto [ 30/May/13 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: The logic for generating machine identifier has changed. Since we are java 6 minimum now, using NetworkInterface.getHardwareAddress() for more uniqueness. The logic for generating process identifier has changed. It attempts to get the actual numeric process id from JMX, falling back to a string hash only if if it can't. It looks for a pattern in the process name of <process_id>@<host_name>. No longer using the classloader hash either, since each class loader will have a separate instance of NEXT_COUNTER, which is seeded with a random number and so is very unlikely to clash. Removed a bunch of stuff Removed support for 'babble' format. Other non-backwards compatible changes: equals method will no longer compare equal to anything but an ObjectId Additionally, added getters that conform to the spec: timestamp, machineIdentifier, processIdentifier, and counter. Deprecated the old ones. |
| Comment by Jeffrey Yemin [ 27/Aug/12 ] |
|
This is incorrect behavior, but have to be careful since changing it could break existing clients who are relying on it. |