[JAVA-1785] ObjectId.compareTo() returns wrong response Created: 29/Apr/15 Updated: 18/Nov/18 Resolved: 30/Apr/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | 3.0.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Pavlos Kranas | Assignee: | Ross Lawley |
| Resolution: | Done | Votes: | 0 |
| Labels: | regression | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
JDK 7.0_51 |
||
| Attachments: |
|
| Backwards Compatibility: | Major Change |
| Description |
|
I have 2 long values [100, 200], with which I create two ObjectId objects, using a byte array This constructs the following two ObjectIds: When i try to compare: obj1.compareTo(obj2)<0 the result is false In v2.x.x versions of the driver, there was a "_compareUnsigned" operation, for handling these comparisons. Is this a bug or this is the way it should work now? |
| Comments |
| Comment by Jeffrey Yemin [ 05/May/15 ] | |||
|
Closed for 3.0.1 release. | |||
| Comment by Githook User [ 30/Apr/15 ] | |||
|
Author: {u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}Message: Fix ObjectId compareTo for Java 6
| |||
| Comment by Githook User [ 30/Apr/15 ] | |||
|
Author: {u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}Message: Fix ObjectId compareTo for Java 6
| |||
| Comment by Githook User [ 30/Apr/15 ] | |||
|
Author: {u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}Message: Fix regression in ObjectId.compareTo Now checks the byte array unsigned int values | |||
| Comment by Ross Lawley [ 30/Apr/15 ] | |||
|
Thanks for reporting pkranas. This has been fixed and will be released in 3.0.1 | |||
| Comment by Githook User [ 30/Apr/15 ] | |||
|
Author: {u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}Message: Fix regression in ObjectId.compareTo Now checks the byte array unsigned int values | |||
| Comment by Ross Lawley [ 29/Apr/15 ] | |||
|
pkranas, my apologies - I do believe this is a regression and counter to how the server compares the ObjectId's. Will confirm and update shortly. | |||
| Comment by Pavlos Kranas [ 29/Apr/15 ] | |||
|
Hi Ross, Thanx for your quick reply I understood what u wrote to me, however my point was that until So from your answer I can assume that this will no longer stand for Thanx in advance for your time, | |||
| Comment by Ross Lawley [ 29/Apr/15 ] | |||
|
Hi pkranas, In 3.0.0 ObjectId was bought up to specification in : An ObjectId is a 12-byte BSON type, constructed using:
So from your example the bytes are:
So from that we get the respective processIdentifier's and so I would expect that:
|