mcgilman commented on code in PR #10749:
URL: https://github.com/apache/nifi/pull/10749#discussion_r2673999037


##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java:
##########
@@ -492,8 +462,14 @@ private void startComponent(final ScheduledExecutorService 
scheduler, final Comp
 
     @Override
     public void verifyCanDelete() {
+        final QueueSize queueSize = 
getActiveFlowContext().getManagedProcessGroup().getQueueSize();
+        if (queueSize.getObjectCount() > 0) {
+            throw new IllegalStateException("Cannot delete " + this + " 
because its Process Group has " + queueSize.getObjectCount()
+                + " FlowFiles queued; all FlowFiles must be removed before it 
can be deleted.");
+        }
+
         final ConnectorState currentState = getCurrentState();
-        if (currentState == ConnectorState.STOPPED || currentState == 
ConnectorState.DISABLED) {
+        if (currentState == ConnectorState.STOPPED) {

Review Comment:
   I know there is a some question about the `UPDATE_FAILED` state but should a 
Connector be delete-able if it's in that state currently?



##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java:
##########
@@ -225,7 +226,18 @@ private ConnectorValueReference createValueReference(final 
VersionedConnectorVal
 
     @Override
     public void applyUpdate() throws FlowUpdateException {
-        applyUpdate(workingFlowContext);
+        try {
+            applyUpdate(workingFlowContext);
+        } catch (final Throwable t) {
+            // Since we failed to update, make sure that we stop the Connector.
+            try (final NarCloseable ignored = 
NarCloseable.withComponentNarLoader(extensionManager, 
connectorDetails.getConnector().getClass(), getIdentifier())) {
+                connectorDetails.getConnector().stop(activeFlowContext);

Review Comment:
   Is this `stop` call necessary? At this point in the update sequence is the 
Connector already stopped? If this happens and when `t` is thrown, I believe 
that it will be caught and trigger a call to `abortUpdate`. Just wanted to 
verify with you this sequence was expected from the Connector implementation 
perspective. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to