You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2016/03/13 02:43:54 UTC
nifi git commit: NIFI-1622: Ensure that the Nar Context Class Loader
is used when calling Processor lifecycle methods
Repository: nifi
Updated Branches:
refs/heads/master a85c11953 -> 7400b6f7c
NIFI-1622: Ensure that the Nar Context Class Loader is used when calling Processor lifecycle methods
Signed-off-by: joewitt <jo...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/7400b6f7
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/7400b6f7
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/7400b6f7
Branch: refs/heads/master
Commit: 7400b6f7c5a6f7ac3a682623772a306610036e72
Parents: a85c119
Author: Mark Payne <ma...@hotmail.com>
Authored: Fri Mar 11 14:51:21 2016 -0500
Committer: joewitt <jo...@apache.org>
Committed: Sat Mar 12 20:06:23 2016 -0500
----------------------------------------------------------------------
.../nifi/controller/StandardProcessorNode.java | 22 ++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/7400b6f7/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
index 85c5fe8..9a6eba5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
@@ -1247,14 +1247,19 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
@SuppressWarnings("deprecation")
@Override
public Void call() throws Exception {
- ReflectionUtils.invokeMethodsWithAnnotations(OnScheduled.class, org.apache.nifi.processor.annotation.OnScheduled.class, processor, schedulingContext);
- return null;
+ try (final NarCloseable nc = NarCloseable.withNarLoader()) {
+ ReflectionUtils.invokeMethodsWithAnnotations(OnScheduled.class, org.apache.nifi.processor.annotation.OnScheduled.class, processor, schedulingContext);
+ return null;
+ }
}
});
if (scheduledState.compareAndSet(ScheduledState.STARTING, ScheduledState.RUNNING)) {
schedulingAgentCallback.run(); // callback provided by StandardProcessScheduler to essentially initiate component's onTrigger() cycle
} else { // can only happen if stopProcessor was called before service was transitioned to RUNNING state
- ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnUnscheduled.class, processor, processContext);
+ try (final NarCloseable nc = NarCloseable.withNarLoader()) {
+ ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnUnscheduled.class, processor, processContext);
+ }
+
scheduledState.set(ScheduledState.STOPPED);
}
} catch (final Exception e) {
@@ -1312,8 +1317,10 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
invokeTaskAsCancelableFuture(scheduler, new Callable<Void>() {
@Override
public Void call() throws Exception {
- ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnUnscheduled.class, processor, processContext);
- return null;
+ try (final NarCloseable nc = NarCloseable.withNarLoader()) {
+ ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnUnscheduled.class, processor, processContext);
+ return null;
+ }
}
});
// will continue to monitor active threads, invoking OnStopped once
@@ -1323,7 +1330,10 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
public void run() {
try {
if (activeThreadMonitorCallback.call()) {
- ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnStopped.class, processor, processContext);
+ try (final NarCloseable nc = NarCloseable.withNarLoader()) {
+ ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnStopped.class, processor, processContext);
+ }
+
scheduledState.set(ScheduledState.STOPPED);
} else {
scheduler.schedule(this, 100, TimeUnit.MILLISECONDS);