You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "jlwt90 (JIRA)" <ji...@apache.org> on 2017/12/10 05:27:00 UTC

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

jlwt90 created NIFI-4686:
----------------------------

             Summary: 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: Minor


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
(v6.4.14#64029)