Skip to content

Commit 3123ba4

Browse files
committed
OAK-12113: MongoDocumentStore: BsonException should be wrapped as DocumentStoreException
1 parent 299cbc8 commit 3123ba4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ private <T extends Document> BulkRequestResult sendBulkRequest(final Collection<
16751675
updateOps.size(), bsonException.getMessage(), idOfbiggestUpdate, estimatedSizeOfBiggestUpdate,
16761676
bsonException);
16771677
// rethrow
1678-
throw bsonException;
1678+
throw new DocumentStoreException(bsonException);
16791679
}
16801680

16811681
for (BulkWriteUpsert upsert : bulkResult.getUpserts()) {

oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,11 @@ public void createOrUpdate16MBBatchWithMultiDocs() {
201201
try {
202202
store.createOrUpdate(Collection.NODES, updateOps);
203203
fail("createOrUpdate(many with one >16MB) should have failed");
204-
} catch (BSONException expected) {
205-
// currently expected but incorrect -> OAK-12113
204+
} catch (DocumentStoreException expected) {
205+
assertTrue("DocumentStoreException should wrap BSONException, but got: "+
206+
expected.getCause(),
207+
expected.getCause() instanceof BSONException);
208+
206209
List<String> messages = log.getLogs();
207210
assertEquals("only 1 message expected, but got: " + messages.size(),
208211
1, messages.size());

0 commit comments

Comments
 (0)