diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java index 356f3f4712..e74457734f 100644 --- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java +++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java @@ -281,7 +281,7 @@ public class GetMongo extends AbstractMongoProcessor { log.debug("Writing batch..."); } String payload = buildBatch(batch, jsonTypeSetting, usePrettyPrint); - writeBatch(payload, null, context, session, attributes, REL_SUCCESS); + writeBatch(payload, input, context, session, attributes, REL_SUCCESS); batch = new ArrayList<>(); } catch (Exception ex) { getLogger().error("Error building batch", ex); @@ -290,7 +290,7 @@ public class GetMongo extends AbstractMongoProcessor { } if (batch.size() > 0) { try { - writeBatch(buildBatch(batch, jsonTypeSetting, usePrettyPrint), null, context, session, attributes, REL_SUCCESS); + writeBatch(buildBatch(batch, jsonTypeSetting, usePrettyPrint), input, context, session, attributes, REL_SUCCESS); } catch (Exception ex) { getLogger().error("Error sending remainder of batch", ex); } diff --git a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java index 4bb0078d0f..2c9b6d2313 100644 --- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java +++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java @@ -427,6 +427,24 @@ public class GetMongoIT { runner.assertTransferCount(GetMongo.REL_ORIGINAL, 0); runner.assertTransferCount(GetMongo.REL_SUCCESS, 3); } + + @Test + public void testReadCharsetWithEL() { + String query = "{ \"c\": { \"$gte\": 4 }}"; + Map attrs = new HashMap<>(); + attrs.put("charset", "UTF-8"); + + runner.setProperty(GetMongo.CHARSET, "${charset}"); + runner.setProperty(GetMongo.BATCH_SIZE, "2"); + runner.setProperty(GetMongo.RESULTS_PER_FLOWFILE, "2"); + + runner.setIncomingConnection(true); + runner.enqueue(query, attrs); + runner.run(1, true, true); + runner.assertTransferCount(GetMongo.REL_FAILURE, 0); + runner.assertTransferCount(GetMongo.REL_ORIGINAL, 1); + runner.assertTransferCount(GetMongo.REL_SUCCESS, 1); + } /* * End query read behavior tests */