I’ve been creating an abstraction of the MongoDB java driver. Given the following block of code…
MongoCollection<Document> col = db.getCollection("something"); col.insertOne(session, someDocument);
Where session can be either null
or an actual instance of ClientSession
. Will I run into issues with this paradigm? I have many methods like this, including col.replaceOne()
, col.deleteOne
, col.countDocuments()
, etc.
Advertisement
Answer
According to the MongoDB Repository, passing in a null ClientSession
will throw an IllegalArgumentException
.