[JAVA-411] Java Driver 2.6.4 findOne fails when fields are specified but no document is found ( NullPointerException ) Created: 09/Aug/11  Updated: 10/Aug/11  Resolved: 09/Aug/11

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.6.4
Fix Version/s: 2.6.5

Type: Bug Priority: Blocker - P1
Reporter: Brendan W. McAdams Assignee: Brendan W. McAdams
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

This is caused by the fix for JAVA-387 ( https://github.com/mongodb/mongo-java-driver/commit/3aee72f1cf814bcbc786a2e04dbce12a81f4cc14 ).

The ternary operator explicitly declares "DBObject obj" as null if no matching document is found, but then with no test attempts to markAsPartialObject which will always throw a NullPointerException in the event findOne() found no matching document.



 Comments   
Comment by Brendan W. McAdams [ 09/Aug/11 ]

Built regression test to reproduce bug, introduced fix.

Comment by auto [ 09/Aug/11 ]

Author:

{u'login': u'bwmcadams', u'name': u'Brendan W. McAdams', u'email': u'brendan@10gen.com'}

Message: Fixes JAVA-411, findOne fails when fields are specified but no document is found ( NullPointerException )

Comment by auto [ 09/Aug/11 ]

Author:

{u'login': u'bwmcadams', u'name': u'Brendan W. McAdams', u'email': u'brendan@10gen.com'}

Message: Refs JAVA-411, findOne fails when fields are specified but no document is found ( NullPointerException )

Comment by Brendan W. McAdams [ 09/Aug/11 ]

It appears to be specifically when the fields argument is passed.

Working on a fix & test now.

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