[JAVA-612] DBRef hashCode is broken Created: 31/Jul/12  Updated: 29/Aug/12  Resolved: 31/Jul/12

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.7.3
Fix Version/s: 2.9.0

Type: Bug Priority: Major - P3
Reporter: Ori Dar Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

DBRef (through DBRefBase) defines an equals() method but no hashCode()
Two equal objects are hashed using Object hashCode() with different hashes.
add, remove, contains etc. don't work properly for hash based collections.



 Comments   
Comment by Jeffrey Yemin [ 29/Aug/12 ]

Closing as part of 2.9.0 release process.

Comment by Jeffrey Yemin [ 31/Jul/12 ]

Also changed DBRefBase#equals so that it does not accept sub-classes. Subclasses that need additional fields includes should override equals/hashCode.

Comment by auto [ 31/Jul/12 ]

Author:

{u'date': u'2012-07-31T05:20:15-07:00', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}

Message: JAVA-612: Properly define equals and hashCode for DBRefBase
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/761f694ee3a096214c68cfe88dbe7e54d2efc335

Generated at Thu Feb 08 08:52:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.