[ 
https://issues.apache.org/jira/browse/NIFI-13715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Handermann updated NIFI-13715:
------------------------------------
    Fix Version/s: 1.28.0

> StandardProvenanceEventRecord.hashCode() is not consistent with equals() in 
> handling Parent/Child FlowFiles
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-13715
>                 URL: https://issues.apache.org/jira/browse/NIFI-13715
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Peter Turcsanyi
>            Assignee: Peter Turcsanyi
>            Priority: Major
>             Fix For: 1.28.0, 2.0.0-M5
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> {{StandardProvenanceEventRecord}} may contain Child FlowFile UUIDs stored in 
> a list (and similarly Parent FlowFile UUIDs in another list). The 
> {{equals()}} method 
> [sorts|https://github.com/apache/nifi/blob/d56f92d738e54b8e9c0ce04606bd7b6259375239/nifi-commons/nifi-data-provenance-utils/src/main/java/org/apache/nifi/provenance/StandardProvenanceEventRecord.java#L400]
>  the UUID lists of the event objects before comparing them and therefore 2 
> event objects are considered equal if they have the same Child FlowFiles but 
> in different order. On the other hand, {{hashCode()}} does not apply sorting 
> and produces different hashes for these equal objects which breaks the 
> equals/hashCode contract: _If two objects are equal according to the equals() 
> method, then the hashCode() method must return the same value for them._
> Real life flow example where the improper {{hashCode()}} method causes an 
> issue:
> QueryRecord with multiple queries and output relationships. The processor's 
> code emits a FORK provenance event with 2+ Child FlowFiles (that many outputs 
> it has). The framework 
> ([StandardProcessSession|https://github.com/apache/nifi/blob/d56f92d738e54b8e9c0ce04606bd7b6259375239/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/StandardProcessSession.java#L849-L851])
>  can also generate the FORK event automatically and it checks if the 
> component has already emitted the event and if yes, it will skip the 
> automatic one. Due to the wrong hashCode() method, this check may fail and in 
> this case 2 FORK events are saved in Provenance repository. This leads to 
> "Unable to generate Lineage Graph because multiple events were registered 
> claiming to have generated the same FlowFile" error when opening the next 
> event after the FORKs.



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

Reply via email to