NIFI-12528: This closes #8180. Fixed bug that resulted in StackOverflowError when deleting loop containing only funnels

Signed-off-by: Joseph Witt <joewitt@apache.org>
This commit is contained in:
Mark Payne 2023-12-21 11:07:39 -05:00 committed by Joseph Witt
parent 2897618635
commit c41b273e82
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
1 changed files with 12 additions and 1 deletions

View File

@ -41,6 +41,7 @@ import org.apache.nifi.remote.RemoteGroupPort;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -500,6 +501,16 @@ public final class StandardConnection implements Connection {
}
private void verifySourceStoppedOrFunnel(final Connection connection) {
verifySourceStoppedOrFunnel(connection, new HashSet<>());
}
private void verifySourceStoppedOrFunnel(final Connection connection, final Set<Connection> connectionsSeen) {
final boolean added = connectionsSeen.add(connection);
if (!added) {
// If we've already seen this Connection, no need to process it again.
return;
}
final Connectable sourceComponent = connection.getSource();
if (!sourceComponent.isRunning()) {
return;
@ -513,7 +524,7 @@ public final class StandardConnection implements Connection {
// Source is a funnel and is running. We need to then check all of its upstream components.
for (final Connection incoming : sourceComponent.getIncomingConnections()) {
verifySourceStoppedOrFunnel(incoming);
verifySourceStoppedOrFunnel(incoming, connectionsSeen);
}
}