NIFIREG-318 Change bootstrap port command handling
diff --git a/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java b/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java
index c3bc172..e7a46b7 100644
--- a/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java
+++ b/nifi-registry-core/nifi-registry-bootstrap/src/main/java/org/apache/nifi/registry/bootstrap/RunNiFiRegistry.java
@@ -99,8 +99,10 @@
     public static final String PING_CMD = "PING";
     public static final String DUMP_CMD = "DUMP";
 
+    private static final int UNINITIALIZED_CC_PORT = -1;
+
     private volatile boolean autoRestartNiFiRegistry = true;
-    private volatile int ccPort = -1;
+    private volatile int ccPort = UNINITIALIZED_CC_PORT;
     private volatile long nifiRegistryPid = -1L;
     private volatile String secretKey;
     private volatile ShutdownHook shutdownHook;
@@ -1178,6 +1180,12 @@
     }
 
     void setNiFiRegistryCommandControlPort(final int port, final String secretKey) throws IOException {
+
+        if (this.secretKey != null && this.ccPort != UNINITIALIZED_CC_PORT) {
+            defaultLogger.warn("Blocking attempt to change NiFi Registry command port and secret after they have already been initialized. requestedPort={}", port);
+            return;
+        }
+
         this.ccPort = port;
         this.secretKey = secretKey;