patricker closed pull request #3203: NIFI-5871 ignore UUID attribute when 
copying flow file attributes
URL: https://github.com/apache/nifi/pull/3203
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java 
b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java
index 1629e96e53..f48b91952d 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockProcessSession.java
@@ -496,7 +496,14 @@ public MockFlowFile putAllAttributes(FlowFile flowFile, 
final Map<String, String
         final MockFlowFile newFlowFile = new MockFlowFile(mock.getId(), 
flowFile);
         currentVersions.put(newFlowFile.getId(), newFlowFile);
 
-        newFlowFile.putAttributes(attrs);
+        final Map<String, String> updatedAttributes;
+        if (attrs.containsKey(CoreAttributes.UUID.key())) {
+            updatedAttributes = new HashMap<>(attrs);
+            updatedAttributes.remove(CoreAttributes.UUID.key());
+        } else {
+            updatedAttributes = attrs;
+        }
+        newFlowFile.putAttributes(updatedAttributes);
         return newFlowFile;
     }
 
diff --git 
a/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/test/java/org/apache/nifi/processors/couchbase/TestPutCouchbaseKey.java
 
b/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/test/java/org/apache/nifi/processors/couchbase/TestPutCouchbaseKey.java
index ce9baa71bd..c32fff792a 100644
--- 
a/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/test/java/org/apache/nifi/processors/couchbase/TestPutCouchbaseKey.java
+++ 
b/nifi-nar-bundles/nifi-couchbase-bundle/nifi-couchbase-processors/src/test/java/org/apache/nifi/processors/couchbase/TestPutCouchbaseKey.java
@@ -268,7 +268,6 @@ public void testInputFlowFileUuid() throws Exception {
 
         ArgumentCaptor<RawJsonDocument> capture = 
ArgumentCaptor.forClass(RawJsonDocument.class);
         verify(bucket, times(1)).upsert(capture.capture(), eq(PersistTo.NONE), 
eq(ReplicateTo.NONE));
-        assertEquals(uuid, capture.getValue().id());
         assertEquals(inFileData, capture.getValue().content());
 
         testRunner.assertTransferCount(REL_SUCCESS, 1);
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestWait.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestWait.java
index a4df2f37e9..5b5b6fcd22 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestWait.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestWait.java
@@ -218,7 +218,6 @@ public void testReplaceAttributes() throws 
InitializationException, IOException
         waitAttributes.put("releaseSignalAttribute", "key");
         waitAttributes.put("wait.only", "waitValue");
         waitAttributes.put("both", "waitValue");
-        waitAttributes.put("uuid", UUID.randomUUID().toString());
         String flowFileContent = "content";
         runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
 
@@ -234,8 +233,6 @@ public void testReplaceAttributes() throws 
InitializationException, IOException
 
         // show a new attribute was copied from the cache
         assertEquals("notifyValue", 
outputFlowFile.getAttribute("notify.only"));
-        // show that uuid was not overwritten
-        assertEquals(waitAttributes.get("uuid"), 
outputFlowFile.getAttribute("uuid"));
         // show that the original attributes are still there
         assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
 
@@ -265,7 +262,6 @@ public void testKeepOriginalAttributes() throws 
InitializationException, IOExcep
         waitAttributes.put("releaseSignalAttribute", "key");
         waitAttributes.put("wait.only", "waitValue");
         waitAttributes.put("both", "waitValue");
-        waitAttributes.put("uuid", UUID.randomUUID().toString());
         String flowFileContent = "content";
         runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
 
@@ -278,8 +274,6 @@ public void testKeepOriginalAttributes() throws 
InitializationException, IOExcep
 
         // show a new attribute was copied from the cache
         assertEquals("notifyValue", 
outputFlowFile.getAttribute("notify.only"));
-        // show that uuid was not overwritten
-        assertEquals(waitAttributes.get("uuid"), 
outputFlowFile.getAttribute("uuid"));
         // show that the original attributes are still there
         assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
 
@@ -307,7 +301,6 @@ public void testWaitForTotalCount() throws 
InitializationException, IOException
         waitAttributes.put("targetSignalCount", "3");
         waitAttributes.put("wait.only", "waitValue");
         waitAttributes.put("both", "waitValue");
-        waitAttributes.put("uuid", UUID.randomUUID().toString());
         String flowFileContent = "content";
         runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
 
@@ -359,8 +352,6 @@ public void testWaitForTotalCount() throws 
InitializationException, IOException
 
         // show a new attribute was copied from the cache
         assertEquals("notifyValue", 
outputFlowFile.getAttribute("notify.only"));
-        // show that uuid was not overwritten
-        assertEquals(waitAttributes.get("uuid"), 
outputFlowFile.getAttribute("uuid"));
         // show that the original attributes are still there
         assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
         // show that the original attribute is kept
@@ -391,7 +382,6 @@ public void testWaitForSpecificCount() throws 
InitializationException, IOExcepti
         waitAttributes.put("signalCounterName", "counter-B");
         waitAttributes.put("wait.only", "waitValue");
         waitAttributes.put("both", "waitValue");
-        waitAttributes.put("uuid", UUID.randomUUID().toString());
         String flowFileContent = "content";
         runner.enqueue(flowFileContent.getBytes("UTF-8"), waitAttributes);
 
@@ -446,8 +436,6 @@ public void testWaitForSpecificCount() throws 
InitializationException, IOExcepti
 
         // show a new attribute was copied from the cache
         assertEquals("notifyValue", 
outputFlowFile.getAttribute("notify.only"));
-        // show that uuid was not overwritten
-        assertEquals(waitAttributes.get("uuid"), 
outputFlowFile.getAttribute("uuid"));
         // show that the original attributes are still there
         assertEquals("waitValue", outputFlowFile.getAttribute("wait.only"));
         // show that the original attribute is kept


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to