NIFI-7347: Fixed NullPointerException that can happen if a bin is merged due to timeout and has no records

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #4210.
This commit is contained in:
Mark Payne 2020-04-14 17:08:49 -04:00 committed by Pierre Villard
parent c9f48e3788
commit a61a4c2b58
No known key found for this signature in database
GPG Key ID: BEE1599F0726E9CD
1 changed files with 10 additions and 10 deletions

View File

@ -124,18 +124,18 @@ public class RecordBin {
logger.debug("Migrating id={} to {}", new Object[] {flowFile.getId(), 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);
recordWriter = writerFactory.createWriter(logger, recordReader.getSchema(), out, flowFile);
recordWriter.beginRecordSet();
}
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});
this.out = new ByteCountingOutputStream(rawOut);
recordWriter = writerFactory.createWriter(logger, record.getSchema(), out, flowFile);
recordWriter.beginRecordSet();
}
recordWriter.write(record);
recordCount++;
}