From 0f775f3a578ad855d4768619d361ff30a0f380ab Mon Sep 17 00:00:00 2001 From: Pierre Villard Date: Tue, 25 Feb 2020 14:00:31 -0800 Subject: [PATCH] NIFI-7195 - Catch MongoException to route flow files to failure This closes #4089 Signed-off-by: Mike Thomsen --- .../org/apache/nifi/processors/mongodb/PutMongoRecord.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongoRecord.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongoRecord.java index 5fbc819c47..39157335a0 100644 --- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongoRecord.java +++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongoRecord.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.processors.mongodb; +import com.mongodb.MongoException; import com.mongodb.WriteConcern; import com.mongodb.client.MongoCollection; import org.apache.nifi.annotation.behavior.EventDriven; @@ -144,7 +145,7 @@ public class PutMongoRecord extends AbstractMongoProcessor { if (inserts.size() > 0) { collection.insertMany(inserts); } - } catch (SchemaNotFoundException | IOException | MalformedRecordException e) { + } catch (SchemaNotFoundException | IOException | MalformedRecordException | MongoException e) { getLogger().error("PutMongoRecord failed with error:", e); session.transfer(flowFile, REL_FAILURE); error = true;