fakemongo / fongo

faked out in-memory mongo for java
Apache License 2.0
523 stars 155 forks source link

InsertManyWriteConcernException should extend BulkWriteException #327

Open Xexanos opened 6 years ago

Xexanos commented 6 years ago

When doing a bulkInsert into an MongoDb, that already has conflicting data in it, the following code throwns an InsertManyWriteConcernException if executed using Fongo:

      BulkWriteOperation bulkWriteOperation = collection.getDbCollection().initializeOrderedBulkOperation();
      dbObjects.forEach(bulkWriteOperation::insert);
      bulkWriteOperation.execute();

The InsertManyWriteConcernException is not part of the actual Mongo driver and therefore never thrown in a production-enviroment. If the InsertManyWriteConcernException would extend BulkWriteException you could catch the same Exception as you would while running with an actual MongoDB. Is there a reason, why you decided to throw your own Exception instead of the one used in the official driver?

jmmut commented 6 years ago

I think this was fixed in #334 and was merged in master. The problem is that the latest stable version 2.1.1 is behind master (currently on fa0d307). Only the 2.2 RCs include the fix. Some more discussion was made on #343.