pvillard31 commented on a change in pull request #4534:
URL: https://github.com/apache/nifi/pull/4534#discussion_r490984606



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java
##########
@@ -781,7 +789,7 @@ public void process(final OutputStream rawOut) throws 
IOException {
                     }
                 });
             } catch (final Exception e) {
-                session.remove(bundle);
+                removeFlowFileFromSession(session, bundle, "Failed to remove 
merged flowfile from the session after merge failure during tar merge.");

Review comment:
       ```suggestion
                   removeFlowFileFromSession(session, bundle, context);
   ```

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java
##########
@@ -636,7 +644,7 @@ public void process(final InputStream in) throws 
IOException {
                     }
                 });
             } catch (final Exception e) {
-                session.remove(bundle);
+                removeFlowFileFromSession(session, bundle, "Failed to remove 
merged flowfile from the session after merge failure during binary 
concatenation merge.");

Review comment:
       ```suggestion
                   removeFlowFileFromSession(session, bundle, context);
   ```

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java
##########
@@ -577,6 +577,14 @@ private boolean isNumber(final String value) {
         return NUMBER_PATTERN.matcher(value).matches();
     }
 
+    private void removeFlowFileFromSession(ProcessSession session, FlowFile 
flowFile, String errorMessage) {
+        try {
+            session.remove(flowFile);
+        } catch (final Exception e) {
+            getLogger().error(errorMessage, e);
+        }
+    }

Review comment:
       ```suggestion
       private void removeFlowFileFromSession(final ProcessSession session, 
final FlowFile flowFile, final ProcessContext context) {
           try {
               session.remove(flowFile);
           } catch (final Exception e) {
               getLogger().error("Failed to remove merged FlowFile from the 
session after merge failure during " + 
context.getProperty(MERGE_FORMAT).getValue() + " merge.", e);
           }
       }
   ```

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java
##########
@@ -848,7 +856,7 @@ public void process(final InputStream rawIn) throws 
IOException {
                     }
                 });
             } catch (final Exception e) {
-                session.remove(bundle);
+                removeFlowFileFromSession(session, bundle, "Failed to remove 
merged flowfile from the session after merge failure during flowfile stream 
merge.");

Review comment:
       ```suggestion
                   removeFlowFileFromSession(session, bundle, context);
   ```

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java
##########
@@ -918,7 +926,7 @@ public void process(final OutputStream rawOut) throws 
IOException {
                     }
                 });
             } catch (final Exception e) {
-                session.remove(bundle);
+                removeFlowFileFromSession(session, bundle, "Failed to remove 
merged flowfile from the session after merge failure during zip merge.");

Review comment:
       ```suggestion
                   removeFlowFileFromSession(session, bundle, context);
   ```

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java
##########
@@ -1042,7 +1050,7 @@ public void process(InputStream in) throws IOException {
                     }
                 });
             } catch (final Exception e) {
-                session.remove(bundle);
+                removeFlowFileFromSession(session, bundle, "Failed to remove 
merged flowfile from the session after merge failure during avro merge.");

Review comment:
       ```suggestion
                   removeFlowFileFromSession(session, bundle, context);
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to