markap14 commented on a change in pull request #3580: NIFI-6436 Fix NPE at StandardPublicPort URL: https://github.com/apache/nifi/pull/3580#discussion_r314045619
########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardPublicPort.java ########## @@ -121,10 +121,12 @@ public StandardPublicPort(final String id, final String name, final ProcessGroup @Override public void reportEvent(final Severity severity, final String category, final String message) { - final String groupId = processGroup.getIdentifier(); - final String groupName = processGroup.getName(); + final String groupId = StandardPublicPort.this.getProcessGroup().getIdentifier(); Review comment: The change to call `getProcessGroup()` here is done because the Process Group provided in the constructor is `null`. This means that we're now technically introducing a race condition in which case a NPE will still be thrown if an event is reported before `setProcessGroup()` gets called. However, in all cases where we construct a `StandardPublicPort` we already know the `ProcessGroup` that we will be placing the Port in. I think there are actually two bugs to address here. Firstly, because a Public Port can be moved from one group to another, this is a good change, to call `getProcessGroup()` instead of relying on the `ProcessGroup` that is passed in. However, this constructor is called only from `StandardFlowManager` and `StandardFlowManager` always passes in `null` for the ProcessGroup. I think this is also a bug. We should either be passing the `ProcessGroup` down the `FlowManager` in order to create the Port, or we should remove the argument from the constructor altogether. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services