NIFI-13545 Improve BootstrapListener getClusterStatus to handle factory being null

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #9078.
This commit is contained in:
Bryan Bende 2024-07-12 15:50:40 -04:00 committed by Pierre Villard
parent a424c0eac3
commit 76a23d921f
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
1 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,8 @@
*/
package org.apache.nifi;
import org.apache.nifi.cluster.ClusterDetailsFactory;
import org.apache.nifi.cluster.ConnectionState;
import org.apache.nifi.controller.DecommissionTask;
import org.apache.nifi.controller.status.history.StatusHistoryDump;
import org.apache.nifi.diagnostics.DiagnosticsDump;
@ -299,7 +301,13 @@ public class BootstrapListener {
}
private String getClusterStatus() {
return nifi.getServer().getClusterDetailsFactory().getConnectionState().name();
final ClusterDetailsFactory clusterDetailsFactory = nifi.getServer().getClusterDetailsFactory();
if (clusterDetailsFactory == null) {
return ConnectionState.UNKNOWN.name();
}
final ConnectionState connectionState = clusterDetailsFactory.getConnectionState();
return connectionState == null ? ConnectionState.UNKNOWN.name() : connectionState.name();
}
private void decommission() throws InterruptedException {