You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/01/28 03:33:00 UTC

[jira] [Commented] (NIFI-4686) MockFlowFile Penalized status is lost after putting attributes

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

ASF GitHub Bot commented on NIFI-4686:
--------------------------------------

GitHub user jlwt90 opened a pull request:

    https://github.com/apache/nifi/pull/2438

    NIFI-4686: MockFlowFile now includes penalized status when copying

    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [x] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [x] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [x] Have you written or updated unit tests to verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jlwt90/nifi NIFI-4686-fix-mockflowfile

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/2438.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2438
    
----
commit 03550a71a083341d440995386d0d93fd623f732e
Author: jlwt90 <ja...@...>
Date:   2018-01-28T02:37:50Z

    NIFI-4686 MockFlowFile now includes penalized status when copying

----


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