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

    https://github.com/apache/nifi/pull/1542#discussion_r104014802
  
    --- 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 --
    
    @olegz I agree that it is a stylistic preference. I don't really mind 
either one. `while(true)` doesn't bother me at all and I believe it's very 
clear -- "continue doing the below until told to stop." The proposal that you 
lay out also relies "on the hope that something in the loop will eventually set 
the value to the assumed stop condition" -- 6 of one, half dozen of the other, 
I think. That being said, I would prefer to keep it as-is over changing the 
code like that for stylistic changes, given that it means that we'd then have 
to re-test to ensure correctness (sure, there are unit tests, but don't I 
wouldn't change something like this without going beyond unit testing and 
testing manually in the application as well).


---
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