This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 5f593207bfd NIFI-15668 Stop Immediately when Run Once requested for
Invalid Processor (#10963)
5f593207bfd is described below
commit 5f593207bfdad3af5484aed1c36c794d4686794b
Author: Pierre Villard <[email protected]>
AuthorDate: Tue Mar 10 15:12:25 2026 +0100
NIFI-15668 Stop Immediately when Run Once requested for Invalid Processor
(#10963)
Signed-off-by: David Handermann <[email protected]>
---
.../apache/nifi/controller/StandardProcessorNode.java | 9 +++++++++
.../apache/nifi/tests/system/processor/RunOnceIT.java | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
index 6d1876a3d2f..82befdb4036 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
@@ -1646,6 +1646,15 @@ public class StandardProcessorNode extends ProcessorNode
implements Connectable
final ValidationStatus validationStatus = getValidationStatus();
if (validationStatus != ValidationStatus.VALID) {
+ if (desiredState == ScheduledState.RUN_ONCE) {
+ final ValidationState validationState =
getValidationState();
+ procLog.warn("Cannot run once {} because Processor is not
valid (Validation State is {}: {}). Returning to stopped.",
+ StandardProcessorNode.this, validationState,
validationState.getValidationErrors());
+ schedulingAgentCallback.onTaskComplete();
+ completeStopAction();
+ return null;
+ }
+
LOG.debug("Cannot start {} because Processor is currently not
valid; will try again after 5 seconds", StandardProcessorNode.this);
startupAttemptCount.incrementAndGet();
diff --git
a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java
b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java
index 8c5d8331fef..0409c4a416b 100644
---
a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java
+++
b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java
@@ -50,4 +50,20 @@ public class RunOnceIT extends NiFiSystemIT {
getClientUtil().waitForStoppedProcessor(generate.getId());
assertEquals(2, getConnectionQueueSize(generateToTerminate.getId()));
}
+
+ @Test
+ public void testRunOnceOnInvalidProcessorShouldReturnToStopped() throws
NiFiClientException, IOException, InterruptedException {
+ final ProcessorEntity generate =
getClientUtil().createProcessor("GenerateFlowFile");
+ final String processorId = generate.getId();
+
+ getClientUtil().waitForValidationCompleted(generate);
+
+ final ProcessorEntity currentEntity =
getNifiClient().getProcessorClient().getProcessor(processorId);
+ assertEquals("INVALID",
currentEntity.getComponent().getValidationStatus(),
+ "Processor should be INVALID because its success relationship
is not connected");
+
+ getNifiClient().getProcessorClient().runProcessorOnce(currentEntity);
+
+ getClientUtil().waitForStoppedProcessor(processorId);
+ }
}