mirror of
https://github.com/apache/nifi.git
synced 2025-02-07 10:38:33 +00:00
NIFI-9389 - NPE guard for ExecuteProcess on no OnTriggered
NIFI-9389 - NPE guard for ExecuteProcess on no OnTriggered
This commit is contained in:
parent
87ef4deb9c
commit
bb0696645e
@ -187,7 +187,7 @@ public class StandardProcessorTestRunner implements TestRunner {
|
||||
|
||||
@Override
|
||||
public void run(final int iterations, final boolean stopOnFinish, final boolean initialize, final long runWait) {
|
||||
if (iterations < 1) {
|
||||
if (iterations < 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class ExecuteProcess extends AbstractProcessor {
|
||||
try {
|
||||
executor.shutdown();
|
||||
} finally {
|
||||
if (this.externalProcess.isAlive()) {
|
||||
if ((this.externalProcess != null) && (this.externalProcess.isAlive())) {
|
||||
this.getLogger().info("Process hasn't terminated, forcing the interrupt");
|
||||
this.externalProcess.destroyForcibly();
|
||||
}
|
||||
|
@ -313,4 +313,15 @@ public class TestExecuteProcess {
|
||||
.anyMatch(m -> m.getMsg().contains("Failed to create process due to")));
|
||||
}
|
||||
|
||||
/**
|
||||
* On configuration of this processor to run only on primary cluster node, other nodes call
|
||||
* {@link org.apache.nifi.annotation.lifecycle.OnUnscheduled} method after an invocation (Start/Stop or RunOnce),
|
||||
* causing an NPE. NPE guard added; test for this situation.
|
||||
*/
|
||||
@Test
|
||||
public void testProcessorNotScheduled() {
|
||||
final TestRunner runner = TestRunners.newTestRunner(ExecuteProcess.class);
|
||||
runner.setProperty(ExecuteProcess.COMMAND, "ls");
|
||||
runner.run(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user