NIFI-8965: Fix duplicate code and typo in StandardFlowManager

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #5265.
This commit is contained in:
Mohammed Nadeem 2021-07-31 13:13:53 +05:30 committed by Pierre Villard
parent 44f7a2f5b5
commit 1ea47d6888
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
1 changed files with 5 additions and 7 deletions

View File

@ -211,7 +211,7 @@ public class StandardFlowManager extends AbstractFlowManager implements FlowMana
final ProcessGroup rootGroup = getRootGroup(); final ProcessGroup rootGroup = getRootGroup();
Port port = rootGroup.findOutputPort(id); Port port = rootGroup.findOutputPort(id);
if (port != null) { if (port != null) {
throw new IllegalStateException("An Input Port already exists with ID " + id); throw new IllegalStateException("An Output Port already exists with ID " + id);
} }
port = rootGroup.findInputPort(id); port = rootGroup.findInputPort(id);
if (port != null) { if (port != null) {
@ -317,7 +317,6 @@ public class StandardFlowManager extends AbstractFlowManager implements FlowMana
.identifier(id) .identifier(id)
.type(type) .type(type)
.bundleCoordinate(coordinate) .bundleCoordinate(coordinate)
.extensionManager(extensionManager)
.controllerServiceProvider(flowController.getControllerServiceProvider()) .controllerServiceProvider(flowController.getControllerServiceProvider())
.processScheduler(processScheduler) .processScheduler(processScheduler)
.nodeTypeProvider(flowController) .nodeTypeProvider(flowController)
@ -344,7 +343,7 @@ public class StandardFlowManager extends AbstractFlowManager implements FlowMana
throw new ComponentLifeCycleException("Failed to invoke @OnAdded methods of " + procNode.getProcessor(), e); throw new ComponentLifeCycleException("Failed to invoke @OnAdded methods of " + procNode.getProcessor(), e);
} }
if (firstTimeAdded && flowController.isInitialized()) { if (flowController.isInitialized()) {
try (final NarCloseable nc = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getProcessor().getIdentifier())) { try (final NarCloseable nc = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getProcessor().getIdentifier())) {
ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnConfigurationRestored.class, procNode.getProcessor()); ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnConfigurationRestored.class, procNode.getProcessor());
} }
@ -360,9 +359,9 @@ public class StandardFlowManager extends AbstractFlowManager implements FlowMana
public ReportingTaskNode createReportingTask(final String type, final String id, final BundleCoordinate bundleCoordinate, final Set<URL> additionalUrls, public ReportingTaskNode createReportingTask(final String type, final String id, final BundleCoordinate bundleCoordinate, final Set<URL> additionalUrls,
final boolean firstTimeAdded, final boolean register) { final boolean firstTimeAdded, final boolean register) {
if (type == null || id == null || bundleCoordinate == null) { requireNonNull(type);
throw new NullPointerException(); requireNonNull(id);
} requireNonNull(bundleCoordinate);
// make sure the first reference to LogRepository happens outside of a NarCloseable so that we use the framework's ClassLoader // make sure the first reference to LogRepository happens outside of a NarCloseable so that we use the framework's ClassLoader
final LogRepository logRepository = LogRepositoryFactory.getRepository(id); final LogRepository logRepository = LogRepositoryFactory.getRepository(id);
@ -372,7 +371,6 @@ public class StandardFlowManager extends AbstractFlowManager implements FlowMana
.identifier(id) .identifier(id)
.type(type) .type(type)
.bundleCoordinate(bundleCoordinate) .bundleCoordinate(bundleCoordinate)
.extensionManager(flowController.getExtensionManager())
.controllerServiceProvider(flowController.getControllerServiceProvider()) .controllerServiceProvider(flowController.getControllerServiceProvider())
.processScheduler(processScheduler) .processScheduler(processScheduler)
.nodeTypeProvider(flowController) .nodeTypeProvider(flowController)