Github user mgaido91 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2392#discussion_r160973717
--- Diff:
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
---
@@ -173,13 +166,25 @@ public void process(final InputStream in) throws
IOException {
// update
final boolean upsert =
context.getProperty(UPSERT).asBoolean();
final String updateKey =
context.getProperty(UPDATE_QUERY_KEY).getValue();
- final Document query = new Document(updateKey,
((Map)doc).get(updateKey));
+ final Document query;
+
+ Object keyVal = ((Map)doc).get(updateKey);
+ if (updateKey.equals("_id")) {
+ try {
+ keyVal = new ObjectId((String) keyVal);
+ } catch (Exception ex) {
+ getLogger().error("{} is not a valid ObjectID,
using raw value.", new Object[]{keyVal});
--- End diff --
what about `keyVal + "is not a valid ObjectID, using raw value."`
---