Skip to content

Commit 496d326

Browse files
committed
[JAVA-276]: findAndModify should eat error on no matched doc, until server is fixed
1 parent 32e57af commit 496d326

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/com/mongodb/DBCollection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,10 @@ public DBObject findAndModify(DBObject query, DBObject fields, DBObject sort, bo
307307
throw new MongoException("FindAndModify: Remove cannot be mixed with the Update, or returnNew params!");
308308

309309
CommandResult res = this._db.command( cmd );
310+
if (res.ok() || res.getErrorMessage().equals( "No matching object found" ))
311+
return (DBObject) res.get( "value" );
310312
res.throwOnError();
311-
return (DBObject) res.get( "value" );
313+
return null;
312314
}
313315

314316

0 commit comments

Comments
 (0)