You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/08/14 18:01:49 UTC

[GitHub] [nifi] mattyb149 commented on a diff in pull request #6264: NIFI-10306: Add logging to StandardProcessGroup.addConnection() with more details

mattyb149 commented on code in PR #6264:
URL: https://github.com/apache/nifi/pull/6264#discussion_r945323865


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java:
##########
@@ -1146,42 +1146,75 @@ public void addConnection(final Connection connection) {
             if (isInputPort(source)) { // if source is an input port, its destination must be in the same group unless it's an input port
                 if (isInputPort(destination)) { // if destination is input port, it must be in a child group.
                     if (!processGroups.containsKey(destinationGroup.getIdentifier())) {
-                        throw new IllegalStateException("Cannot add Connection to Process Group because destination is an Input Port that does not belong to a child Process Group");
+                        throw new IllegalStateException("Cannot add Connection for Input Port[" + source.getIdentifier() +
+                                "] from Process Group [" + sourceGroup.getIdentifier() +
+                                "] to Process Group [" + destinationGroup.getIdentifier() +
+                                "] because destination [" + destination.getIdentifier() +
+                                "] is an Input Port that does not belong to a child Process Group");
                     }
                 } else if (sourceGroup != this || destinationGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection to Process Group because source and destination are not both in this Process Group");
+                    throw new IllegalStateException("Cannot add Connection for Input Port[" + source.getIdentifier() +
+                            "] from Process Group [" + sourceGroup.getIdentifier() +
+                            "] to Process Group [" + destinationGroup.getIdentifier() +
+                            "] destination [" + destination.getIdentifier() +
+                            "] because source and destination are not both in this Process Group");
                 }
             } else if (isOutputPort(source)) {
                 // if source is an output port, its group must be a child of this group, and its destination must be in this
                 // group (processor/output port) or a child group (input port)
                 if (!processGroups.containsKey(sourceGroup.getIdentifier())) {
-                    throw new IllegalStateException("Cannot add Connection to Process Group because source is an Output Port that does not belong to a child Process Group");
+                    throw new IllegalStateException("Cannot add Connection for Output Port[" + source.getIdentifier() +
+                            "] from Process Group [" + sourceGroup.getIdentifier() +
+                            "] to Process Group [" + destinationGroup.getIdentifier() +
+                            "] destination [" + destination.getIdentifier() +
+                            "] because source is an Output Port that does not belong to a child Process Group");
                 }
 
                 if (isInputPort(destination)) {
                     if (!processGroups.containsKey(destinationGroup.getIdentifier())) {
-                        throw new IllegalStateException("Cannot add Connection to Process Group because its destination is an Input Port that does not belong to a child Process Group");
+                        throw new IllegalStateException("Cannot add Connection for Output Port[" + source.getIdentifier() +
+                                "] from Process Group [" + sourceGroup.getIdentifier() +
+                                "] to Process Group [" + destinationGroup.getIdentifier() +
+                                "] because destination [" + destination.getIdentifier() +
+                                "] is an Input Port that does not belong to a child Process Group");
                     }
                 } else if (destinationGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection to Process Group because its destination does not belong to this Process Group");
+                    throw new IllegalStateException("Cannot add Connection for Output Port[" + source.getIdentifier() +
+                            "] from Process Group [" + sourceGroup.getIdentifier() +
+                            "] to Process Group [" + destinationGroup.getIdentifier() +
+                            "] because its destination [" + destination.getIdentifier() +
+                            "] does not belong to this Process Group");
                 }
             } else { // source is not a port
                 if (sourceGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection to Process Group because the source does not belong to this Process Group");
+                    throw new IllegalStateException("Cannot add Connection from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                            "] from Process Group [" + sourceGroup.getIdentifier() +
+                            "] to Process Group [" + destinationGroup.getIdentifier() +
+                            "] because the source does not belong to this Process Group");
                 }
 
                 if (isOutputPort(destination)) {
                     if (destinationGroup != this) {
-                        throw new IllegalStateException("Cannot add Connection to Process Group because its destination is an Output Port but does not belong to this Process Group");
+                        throw new IllegalStateException("Cannot add Connection from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                                "] from Process Group [" + sourceGroup.getIdentifier() +
+                                "] to Process Group [" + destinationGroup.getIdentifier() +
+                                "] because its destination [" + destination.getIdentifier() +
+                                "] is an Output Port that does not belong to this Process Group");
                     }
                 } else if (isInputPort(destination)) {
                     if (!processGroups.containsKey(destinationGroup.getIdentifier())) {
-                        throw new IllegalStateException("Cannot add Connection to Process Group because its destination is an Input "
-                            + "Port but the Input Port does not belong to a child Process Group");
+                        throw new IllegalStateException("Cannot add Connection from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                                "] from Process Group [" + sourceGroup.getIdentifier() +
+                                "] to Process Group [" + destinationGroup.getIdentifier() +
+                                "] because its destination [" + destination.getIdentifier() +
+                                "] is an Input Port but the Input Port does not belong to a child Process Group");
                     }
                 } else if (destinationGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection between " + source.getIdentifier() + " and " + destination.getIdentifier()
-                        + " because they are in different Process Groups and neither is an Input Port or Output Port");
+                    throw new IllegalStateException("Cannot add Connection from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                            "] from Process Group [" + sourceGroup.getIdentifier() +
+                            "] to Process Group [" + destinationGroup.getIdentifier() +
+                            "] destination " + destination.getConnectableType().name() + "[" + destination.getIdentifier() +

Review Comment:
   The others should have the connectable type hard-coded into the string. I can change them all in order to externalize a method that takes the groups and such as arguments and return the formatted string.



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org