[ 
https://issues.apache.org/jira/browse/NIFI-15523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18055720#comment-18055720
 ] 

ASF subversion and git services commented on NIFI-15523:
--------------------------------------------------------

Commit 2610c5cacbd154e06f3cab6130e5ad52c53d480e in nifi's branch 
refs/heads/main from David Young
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=2610c5cacb ]

NIFI-15523 Fixed Provenance EventIterator factory not returning items (#10837)

- EventIterator created using the `of` factory would return Optional.empty() 
when there are actually items in the internal iterator
- Flipping the ternary result expressions fixed this issue

Signed-off-by: David Handermann <[email protected]>

> Provenance EventIterator#of doesn't return any events
> -----------------------------------------------------
>
>                 Key: NIFI-15523
>                 URL: https://issues.apache.org/jira/browse/NIFI-15523
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: David Young
>            Assignee: David Young
>            Priority: Minor
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Although it doesn't appear to be actually used anywhere, an EventIterator 
> that is created using the static `of` method will never actually return any 
> events.
> [Source|https://github.com/apache/nifi/blob/4f99d4a3786ef8f2472ccfe73a42dd5d316c76aa/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/iterator/EventIterator.java#L45-L57]:
> {code:java}
> static EventIterator of(final ProvenanceEventRecord... events) {
>     final Iterator<ProvenanceEventRecord> itr = 
> Arrays.asList(events).iterator();
>     return new EventIterator() {
>         @Override
>         public void close() throws IOException {
>         }
>         @Override
>         public Optional<ProvenanceEventRecord> nextEvent() {
>             return itr.hasNext() ? Optional.empty() : Optional.of(itr.next());
>         }
>     };
> }{code}
> The conditions in the `nextEvent` method need to be swapped:
> {code:java}
> return itr.hasNext() ? Optional.of(itr.next()) : Optional.empty();
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to