exceptionfactory commented on code in PR #8648:
URL: https://github.com/apache/nifi/pull/8648#discussion_r1568893275


##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String 
flowConfigFileLocation) throws C
         }
     }
 
-    private Process startMiNiFi() throws IOException {
+    private Process startMiNiFi(BootstrapProperties bootstrapProperties) 
throws IOException {
+        int bootstrapListenPort = 
parseBootstrapListenPort(bootstrapProperties);
+
         MiNiFiListener listener = new MiNiFiListener();
-        listenPort = listener.start(runMiNiFi, bootstrapFileProvider, 
configurationChangeListener);
+        listenPort = listener.start(runMiNiFi, bootstrapListenPort, 
bootstrapFileProvider, configurationChangeListener);
 
         CMD_LOGGER.info("Starting Apache MiNiFi...");
 
         return startMiNiFiProcess(getProcessBuilder());
     }
 
+    private int parseBootstrapListenPort(BootstrapProperties 
bootstrapProperties) {
+        String bootstrapListenPort = 
bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+        int parsedBootstrapListenPort = 
Optional.ofNullable(bootstrapListenPort)
+            .map(String::trim)
+            .map(port -> {
+                try {
+                    return Integer.parseInt(port);
+                } catch (NumberFormatException e) {
+                    throw new IllegalArgumentException("Unable to parse 
bootstrap listen port, please provide a valid port for " + 
NIFI_BOOTSTRAP_LISTEN_PORT);
+                }
+            })
+            .orElse(0);
+        CMD_LOGGER.info("Using boostrap listen port {}", 
parsedBootstrapListenPort);

Review Comment:
   Minor spelling correction, wording adjustment recommendation:
   ```suggestion
           CMD_LOGGER.info("Bootstrap listen port {}", 
parsedBootstrapListenPort);
   ```



##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/command/StartRunner.java:
##########
@@ -279,15 +280,33 @@ private void regenerateFlowConfiguration(String 
flowConfigFileLocation) throws C
         }
     }
 
-    private Process startMiNiFi() throws IOException {
+    private Process startMiNiFi(BootstrapProperties bootstrapProperties) 
throws IOException {
+        int bootstrapListenPort = 
parseBootstrapListenPort(bootstrapProperties);
+
         MiNiFiListener listener = new MiNiFiListener();
-        listenPort = listener.start(runMiNiFi, bootstrapFileProvider, 
configurationChangeListener);
+        listenPort = listener.start(runMiNiFi, bootstrapListenPort, 
bootstrapFileProvider, configurationChangeListener);
 
         CMD_LOGGER.info("Starting Apache MiNiFi...");
 
         return startMiNiFiProcess(getProcessBuilder());
     }
 
+    private int parseBootstrapListenPort(BootstrapProperties 
bootstrapProperties) {
+        String bootstrapListenPort = 
bootstrapProperties.getProperty(NIFI_BOOTSTRAP_LISTEN_PORT);
+        int parsedBootstrapListenPort = 
Optional.ofNullable(bootstrapListenPort)
+            .map(String::trim)
+            .map(port -> {
+                try {
+                    return Integer.parseInt(port);
+                } catch (NumberFormatException e) {
+                    throw new IllegalArgumentException("Unable to parse 
bootstrap listen port, please provide a valid port for " + 
NIFI_BOOTSTRAP_LISTEN_PORT);

Review Comment:
   Minor adjustment, recommend capitalizing Bootstrap:
   ```suggestion
                       throw new IllegalArgumentException("Unable to parse 
Bootstrap listen port, please provide a valid port for " + 
NIFI_BOOTSTRAP_LISTEN_PORT);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to