From 2595d816c4c9ef47a66f1aed477932c589588823 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Sat, 27 May 2017 14:55:04 -0400 Subject: [PATCH] NIFI-3986: This closes #1868. When we encounted EOFException from sequential record reader event iterator, just treat it as not having any more events Signed-off-by: joewitt --- .../SequentialRecordReaderEventIterator.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/iterator/SequentialRecordReaderEventIterator.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/iterator/SequentialRecordReaderEventIterator.java index 869febfb6b..98fe9cd6b2 100644 --- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/iterator/SequentialRecordReaderEventIterator.java +++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/iterator/SequentialRecordReaderEventIterator.java @@ -68,7 +68,18 @@ public class SequentialRecordReaderEventIterator implements EventIterator { } while (true) { - final ProvenanceEventRecord event = reader.nextRecord(); + ProvenanceEventRecord event; + try { + event = reader.nextRecord(); + } catch (final EOFException eof) { + // We have run out of data. Treat the same as getting back null. + // This happens particularly if reading the same file that is being + // written to (because we use a BufferedOutputStream to write to it, so we + // may read half-way through a record and then hit the end of what was + // buffered and flushed). + event = null; + } + if (event == null) { if (rotateReader()) { continue;