-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.3.0
-
Component/s: Async
-
Labels:None
The updateOne command below works with MongoDB Java driver 3.3.0 but does not work with MongoDB Async Java driver 3.3.0.
MongoAsync Driver does not work:
public void upsertForReal(MongoCollection<Document> mCollection, Document query, Document upsert) { mCollection.updateOne(query, upsert, new UpdateOptions().upsert(true), new SingleResultCallback<UpdateResult>() { @Override public void onResult(UpdateResult result, Throwable e) { if (e!=null) { log.error("Upsert failed", e); } if (log.isDebugEnabled()) { log.debug("The upsert query "+query+" returned matchedCount="+result.getMatchedCount()+ " modifiedCount= "+result.getModifiedCount()); } } }); }
Mongo driver works:
public void upsertForReal(MongoCollection<Document> mCollection, Document query, Document upsert) { mCollection.updateOne(query, upsert, new UpdateOptions().upsert(true)); }
The MongoAsync driver does not report any issues. The document simply does not get inserted if the query document does not match.