You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Mark Payne (JIRA)" <ji...@apache.org> on 2019/07/03 18:51:00 UTC

[jira] [Commented] (NIFI-6420) Controller Service references not properly tracked if multiple references from same component

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

Mark Payne commented on NIFI-6420:
----------------------------------

The following integration test can be used to replicate this:
{code:java}
@Test
public void testReferenceCounts() {
    final ControllerServiceNode serviceNode = createControllerServiceNode(LongValidatingControllerService.class.getName());
    serviceNode.setProperties(Collections.singletonMap(LongValidatingControllerService.DELAY.getName(), "250 millis"));

    final ProcessorNode counter = createProcessorNode(ControllerServiceReferencingProcessor.class);

    final Map<String, String> properties = new HashMap<>();

    properties.put(ControllerServiceReferencingProcessor.OPTIONAL_SERVICE.getName(), serviceNode.getIdentifier());
    counter.setProperties(properties);
    assertEquals(1, serviceNode.getReferences().getReferencingComponents().size());

    properties.put(ControllerServiceReferencingProcessor.IGNORED_OPTIONAL_SERVICE.getName(), serviceNode.getIdentifier());
    counter.setProperties(properties);
    assertEquals(1, serviceNode.getReferences().getReferencingComponents().size());

    properties.put(ControllerServiceReferencingProcessor.IGNORED_OPTIONAL_SERVICE.getName(), null);
    counter.setProperties(properties);
    assertEquals(1, serviceNode.getReferences().getReferencingComponents().size());

    properties.clear();
    properties.put(ControllerServiceReferencingProcessor.OPTIONAL_SERVICE.getName(), null);
    counter.setProperties(properties);
    assertEquals(0, serviceNode.getReferences().getReferencingComponents().size());
}{code}

> Controller Service references not properly tracked if multiple references from same component
> ---------------------------------------------------------------------------------------------
>
>                 Key: NIFI-6420
>                 URL: https://issues.apache.org/jira/browse/NIFI-6420
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>            Reporter: Mark Payne
>            Priority: Major
>
> The StandardControllerServiceNode keeps track of any references to it via `addReference` and `removeReference` methods. However, if a Processor (or another Controller Service) has two different properties that reference the service, then the references can become incorrect.
> This is due to the fact that when Properties are set for a component, we determine that Property A previously referenced Service 123 but no longer does and call `removeReference` on Service 123. However, if Property B also is referencing Service 123, we have a condition where the Processor is referencing Service 123, but Service 123 does not know about it, because of the call to `removeReference`.
> We should either be storing references as a `List` in `StandardControllerServiceNode` or else should determine whether or not all references have been removed before calling `removeReference`. I suspect that the latter is less error-prone, given that calls to `addReference` currently are idempotent and changing the data structure to a `List` would mean that the method is no longer idempotent.



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