[JAVA-2841] BasicBSONObject and BasicDBObject not equal in 3.8.0-beta1 Created: 24/Apr/18  Updated: 28/Oct/23  Resolved: 25/Apr/18

Status: Closed
Project: Java Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 3.7.0

Type: Bug Priority: Major - P3
Reporter: John Morales Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS X
Oracle Hotspot Java 8u161
Java Driver versions: 3.7.0-rc0 and 3.8.0-beta1


Issue Links:
Depends

 Description   

Example:

  @Test
  public void bsonObjectVsDBObject() throws Exception {
    assertEquals(
        new BasicDBObject("_id", new ObjectId("5adf5c14ac34ea1322706a06")),
        new BasicBSONObject("_id", new ObjectId("5adf5c14ac34ea1322706a06")));
  }

Test fails on both 3.7.0-rc0 and 3.8.0-beta1 while passes on 3.6.3:

java.lang.AssertionError: 
Expected :{ "_id" : { "$oid" : "5adf5c14ac34ea1322706a06" } }
Actual   :{_id=5adf5c14ac34ea1322706a06}



 Comments   
Comment by Githook User [ 25/Apr/18 ]

Author:

{'email': 'ross.lawley@gmail.com', 'username': 'rozza', 'name': 'Ross Lawley'}

Message: Relax type comparision in BasicDBObject#equals

Allow comparison against other BSONObject types

JAVA-2841
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f6482876d8f2ead8d0bcaa89f20755a7c4a00642

Comment by Githook User [ 25/Apr/18 ]

Author:

{'email': 'ross.lawley@gmail.com', 'username': 'rozza', 'name': 'Ross Lawley'}

Message: Relax type comparision in BasicDBObject#equals

Allow comparison against other BSONObject types

JAVA-2841
Branch: 3.7.x
https://github.com/mongodb/mongo-java-driver/commit/654ec7f67107e1a730b389debd727d5df0a5b5ca

Comment by Jeffrey Yemin [ 24/Apr/18 ]

It's not symmetrical, as this test passes:

    @Test
    public void bsonObjectVsDBObject() throws Exception {
        assertEquals(
                new BasicBSONObject("_id", new ObjectId("5adf5c14ac34ea1322706a06")),
                new BasicDBObject("_id", new ObjectId("5adf5c14ac34ea1322706a06")));
    }

Comment by Jeffrey Yemin [ 24/Apr/18 ]

https://github.com/mongodb/mongo-java-driver/commit/66531c9601f622711e4190a8358275611e395801 looks like what broke it.

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