You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2020/04/15 10:39:25 UTC

[nifi] branch master updated: NIFI-7347: Fixed NullPointerException that can happen if a bin is merged due to timeout and has no records

This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new a61a4c2  NIFI-7347: Fixed NullPointerException that can happen if a bin is merged due to timeout and has no records
a61a4c2 is described below

commit a61a4c2b5878f53777df8df1dd91a78629ba23bb
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Tue Apr 14 17:08:49 2020 -0400

    NIFI-7347: Fixed NullPointerException that can happen if a bin is merged due to timeout and has no records
    
    Signed-off-by: Pierre Villard <pi...@gmail.com>
    
    This closes #4210.
---
 .../nifi/processors/standard/merge/RecordBin.java      | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/merge/RecordBin.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/merge/RecordBin.java
index c3dbbaa..b49fc2a 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/merge/RecordBin.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/merge/RecordBin.java
@@ -124,18 +124,18 @@ public class RecordBin {
 
             logger.debug("Migrating id={} to {}", new Object[] {flowFile.getId(), this});
 
-            Record record;
-            while ((record = recordReader.nextRecord()) != null) {
-                if (recordWriter == null) {
-                    final OutputStream rawOut = session.write(merged);
-                    logger.debug("Created OutputStream using session {} for {}", new Object[] {session, this});
+            if (recordWriter == null) {
+                final OutputStream rawOut = session.write(merged);
+                logger.debug("Created OutputStream using session {} for {}", new Object[] {session, this});
 
-                    this.out = new ByteCountingOutputStream(rawOut);
+                this.out = new ByteCountingOutputStream(rawOut);
 
-                    recordWriter = writerFactory.createWriter(logger, record.getSchema(), out, flowFile);
-                    recordWriter.beginRecordSet();
-                }
+                recordWriter = writerFactory.createWriter(logger, recordReader.getSchema(), out, flowFile);
+                recordWriter.beginRecordSet();
+            }
 
+            Record record;
+            while ((record = recordReader.nextRecord()) != null) {
                 recordWriter.write(record);
                 recordCount++;
             }