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

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

Commit d8cfb8e6c516698d65880bbc86a10048b9fbcab8 in nifi's branch 
refs/heads/master from [~jlwt90]
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=d8cfb8e ]

NIFI-4686 MockFlowFile now includes penalized status when copying. This closes 
#2438.

Signed-off-by: Mark Payne <[email protected]>


> MockFlowFile Penalized status is lost after putting attributes
> --------------------------------------------------------------
>
>                 Key: NIFI-4686
>                 URL: https://issues.apache.org/jira/browse/NIFI-4686
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: jlwt90
>            Priority: Major
>
> Hello,
> When I write unit tests to test whether a FlowFile is penalised after an 
> exception is thrown by an external resource, I find a possible issue in the 
> current *MockFlowFile* class.
> I first penalized the FlowFile and put a *Error* attribute to the file 
> afterwards. The class attribute *penalized* will be reset after the calling 
> {code}session.putAttributes(xxx){code} function.
> Here is the unit test I added to the test class *TestMockProcessSession*.
> {code}
>     @Test
>     public void testKeepPenalizedStatusAfterPuttingAttribute(){
>         final Processor processor = new PoorlyBehavedProcessor();
>         final MockProcessSession session = new MockProcessSession(new 
> SharedSessionState(processor, new AtomicLong(0L)), processor);
>         FlowFile ff1 = session.createFlowFile("hello, world".getBytes());
>         ff1 = session.penalize(ff1);
>         assertEquals(ff1.isPenalized(), true);
>         ff1 = session.putAttribute(ff1, "hello", "world");
>         assertEquals(ff1.isPenalized(), true);
>     }
> {code}
> In the current MockFlowFile implementation:
> {code}
> public MockFlowFile(final long id, final FlowFile toCopy) {}
> {code}
> Class attribute *penalized* will not be copied and therefore, this test will 
> fail.
> I think this behaviour is unexpected and checked how this logic is 
> implemented in *StandardFlowFileRecord*.
> https://github.com/apache/nifi/blob/c138987bb46b975379daa00e57c42f498b6ef207/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-repository-models/src/main/java/org/apache/nifi/controller/repository/StandardFlowFileRecord.java#L320
> *Calling method in StandardProcessSession:*
> https://github.com/apache/nifi/blob/c138987bb46b975379daa00e57c42f498b6ef207/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/StandardProcessSession.java#L1756
> Could you please advise whether this is a bug? The fix is simple and I would 
> like to submit the change if needed. :)
> Thanks!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to