This is an automated email from the ASF dual-hosted git repository.

ferdei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 660d0ed5f9 NIFI-11023 Address socket communication instability between 
minifi process and bootstrap
660d0ed5f9 is described below

commit 660d0ed5f9abc84e225d8f0fc0209f5cffe2e1bd
Author: Csaba Bejan <bejan.cs...@gmail.com>
AuthorDate: Tue Jan 3 17:49:05 2023 +0100

    NIFI-11023 Address socket communication instability between minifi process 
and bootstrap
    
    Signed-off-by: Ferenc Erdei <erdei.feren...@gmail.com>
    This closes #6820
---
 .../org/apache/nifi/minifi/bootstrap/service/MiNiFiCommandSender.java  | 2 ++
 .../main/java/org/apache/nifi/minifi/bootstrap/BootstrapListener.java  | 3 +++
 2 files changed, 5 insertions(+)

diff --git 
a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiCommandSender.java
 
b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiCommandSender.java
index 77595c046e..f2a3be2c3b 100644
--- 
a/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiCommandSender.java
+++ 
b/minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/MiNiFiCommandSender.java
@@ -61,6 +61,7 @@ public class MiNiFiCommandSender {
             LOGGER.debug("Connecting to MiNiFi instance");
             socket.setSoTimeout(SOCKET_TIMEOUT);
             socket.connect(new InetSocketAddress("localhost", port), 
CONNECTION_TIMEOUT);
+            socket.setSoTimeout(SOCKET_TIMEOUT);
             LOGGER.debug("Established connection to MiNiFi instance.");
 
             LOGGER.debug("Sending {} Command to port {}", cmd, port);
@@ -76,6 +77,7 @@ public class MiNiFiCommandSender {
             response = Optional.of(responseString);
         } catch (EOFException | SocketTimeoutException e) {
             String message = "Failed to get response for " + cmd + " 
Potentially due to the process currently being down (restarting or otherwise)";
+            LOGGER.error(message, e);
             throw new RuntimeException(message);
         }
         return response;
diff --git 
a/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-runtime/src/main/java/org/apache/nifi/minifi/bootstrap/BootstrapListener.java
 
b/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-runtime/src/main/java/org/apache/nifi/minifi/bootstrap/BootstrapListener.java
index 575645d855..07791b1ea8 100644
--- 
a/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-runtime/src/main/java/org/apache/nifi/minifi/bootstrap/BootstrapListener.java
+++ 
b/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-runtime/src/main/java/org/apache/nifi/minifi/bootstrap/BootstrapListener.java
@@ -154,11 +154,13 @@ public class BootstrapListener implements 
BootstrapCommunicator {
         messageHandlers.putIfAbsent(RELOAD, (args, outputStream) -> {
             logger.info("Received RELOAD request from Bootstrap");
             echoRequestCmd(RELOAD, outputStream);
+            logger.info("Responded to RELOAD request from Bootstrap, stopping 
MiNiFi Server");
             minifiServer.stop(true);
         });
         messageHandlers.putIfAbsent(SHUTDOWN, (args, outputStream) -> {
             logger.info("Received SHUTDOWN request from Bootstrap");
             echoRequestCmd(SHUTDOWN, outputStream);
+            logger.info("Responded to SHUTDOWN request from Bootstrap, 
stopping MiNiFi Server");
             minifiServer.stop(false);
         });
         messageHandlers.putIfAbsent("DUMP", (args, outputStream) -> {
@@ -292,6 +294,7 @@ public class BootstrapListener implements 
BootstrapCommunicator {
         try {
             out.write((cmd + "\n").getBytes(StandardCharsets.UTF_8));
             out.flush();
+            out.close();
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }

Reply via email to