Skip to content

Commit 58e6abf

Browse files
committed
Made DBCollection.findOne overloads that take the _id value go through the same code path as the other findOne methods.
This fixes a bug where the read preference is not being correctly applied when connected to a mongos JAVA-1473
1 parent b4e9133 commit 58e6abf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/com/mongodb/DBCollection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ public DBObject findOne( Object obj ){
378378
* @mongodb.driver.manual tutorial/query-documents/ Query
379379
*/
380380
public DBObject findOne( Object obj, DBObject fields ){
381-
Iterator<DBObject> iterator = find(new BasicDBObject("_id", obj), fields, 0, -1, 0, getOptions(), getReadPreference(), getDecoder());
382-
return (iterator.hasNext() ? iterator.next() : null);
381+
return findOne(new BasicDBObject("_id", obj), fields);
383382
}
384383

385384
/**

0 commit comments

Comments
 (0)