[JAVA-1629] DBCursor getters should not return copies for mutable objects Created: 22/Jan/15  Updated: 31/Mar/15  Resolved: 23/Jan/15

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: None
Fix Version/s: 3.0.0

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


 Description   

The 3.0.x branch implementation of DBCursor.getQuery and DBCursor.getKeysWanted return a copy of the internal property, whereas before they returned a reference to the internal copy. This break clients who do:

DBCursor cursor = collection.find(new BasicDBObject());
cursor.getQuery().put("x", 1);

since because getQuery returns a copy, the put has no effect on the query that's actually performed.

This should be reverted to the previous behavior.



 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 Githook User [ 30/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Changed DBCursor behavior such that any method that returns a DBObject property of the query returns the internal reference instead of a copy of it,
which is the behavior in 2.x and allows an idiom where the caller keeps tacking on criteria/keys to the internal DBObject instead of setting them all at
once beforehand.

Thanks to the MongoJack tests for alerting us to this behavior change.

JAVA-1629
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/83d74fc4edf6f7840af5ad284f19d780a04320cd

Comment by Githook User [ 23/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Changed DBCursor behavior such that any method that returns a DBObject property of the query returns the internal reference instead of a copy of it,
which is the behavior in 2.x and allows an idiom where the caller keeps tacking on criteria/keys to the internal DBObject instead of setting them all at
once beforehand.

Thanks to the MongoJack tests for alerting us to this behavior change.

JAVA-1629
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/83d74fc4edf6f7840af5ad284f19d780a04320cd

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