-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 3.0.0
-
Component/s: BSON
-
Environment:JDK 7.0_51
-
Major Change
I have 2 long values [100, 200], with which I create two ObjectId objects, using a byte array
byte1 = byte [] bytes = ByteBuffer.allocate(12).putLong(value1).put(new byte[4]).array()
objectId1 = ObjectId(byte1)
This constructs the following two ObjectIds:
obj1 = 000000000000006400000000
obj2 = 00000000000000c800000000
When i try to compare: obj1.compareTo(obj2)<0 the result is false
This happens because obj1's processIdentifier value (bytes "6400") is set to value "25600", while the obj2's processIdentifier value (bytes "c800") is set to the signed "-14336".
So the comparison "x = processIdentifier - other.processIdentifier;" is positive and obj1.compareTo(obj2)<0 returns 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?