Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1542#discussion_r103749486
  
    --- Diff: 
nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/serialization/CompressableRecordReader.java
 ---
    @@ -283,7 +283,20 @@ public StandardProvenanceEventRecord nextRecord() 
throws IOException {
             }
     
             if (isData()) {
    -            return nextRecord(dis, serializationVersion);
    +            while (true) {
    +                try {
    +                    return nextRecord(dis, serializationVersion);
    +                } catch (final IOException ioe) {
    +                    throw ioe;
    +                } catch (final Exception e) {
    +                    // This would only happen if a bug were to exist such 
that an 'invalid' event were written
    +                    // out. For example an Event that has no FlowFile 
UUID. While there is in fact an underlying
    +                    // cause that would need to be sorted out in this 
case, the Provenance Repository should be
    +                    // resilient enough to handle this. Otherwise, we end 
up throwing an Exception, which may
    +                    // prevent iterating over additional events in the 
repository.
    +                    logger.error("Failed to read Provenance Event from " + 
filename + "; will skip this event and continue reading subsequent events", e);
    +                }
    +            }
    --- End diff --
    
    Perhaps a style preference, but IMHO it would look better like this:
    ```
    StandardProvenanceEventRecord record = null;
     do {
            try {
                 record = nextRecord(dis, serializationVersion);
            } catch (IOException e) {
                        // . . .
            } catch (Exception e) {
                        // . . .
            }
    } while (record == null);
    return record;
    ```
    First, it avoids the ```while(true)``` which essentially relies on the hope 
that something in the loop will eventually break it.
    Second it follows the general pattern of reading (e.g., from InputStream) 
used in Reader implementations.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to