Skip to content

Commit f25ef2b

Browse files
author
Brendan W. McAdams
committed
Refs JAVA-411, findOne fails when fields are specified but no document is found ( NullPointerException )
* Regression test for this case that tests for a null findOne w/ fields specified
1 parent 10026dc commit f25ef2b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/test/com/mongodb/DBCollectionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public void testFindOne() {
5959
obj = c.findOne(null, null);
6060
assertEquals(obj, null);
6161

62+
// Test that findOne works when fields is specified but no match is found
63+
// *** This is a Regression test for JAVA-411 ***
64+
obj = c.findOne(null, new BasicDBObject("_id", true));
65+
66+
assertEquals(obj, null);
67+
6268
DBObject inserted = BasicDBObjectBuilder.start().add("x",1).add("y",2).get();
6369
c.insert(inserted);
6470
c.insert(BasicDBObjectBuilder.start().add("_id", 123).add("x",2).add("z",2).get());

0 commit comments

Comments
 (0)