From 2abb8921e7a990715f38d1615b930055747467ef Mon Sep 17 00:00:00 2001 From: Ferenc Erdei Date: Mon, 16 Jan 2023 20:06:08 +0100 Subject: [PATCH] NIFI-10895 Handle minifi restarts more gracefully Signed-off-by: Csaba Bejan This closes #6852. --- .../org/apache/nifi/minifi/c2/C2NifiClientService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-framework-core/src/main/java/org/apache/nifi/minifi/c2/C2NifiClientService.java b/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-framework-core/src/main/java/org/apache/nifi/minifi/c2/C2NifiClientService.java index d56e0d7ce3..ad8f5e5e26 100644 --- a/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-framework-core/src/main/java/org/apache/nifi/minifi/c2/C2NifiClientService.java +++ b/minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-framework-core/src/main/java/org/apache/nifi/minifi/c2/C2NifiClientService.java @@ -305,11 +305,15 @@ public class C2NifiClientService { } public void stop() { + bootstrapAcknowledgeExecutorService.shutdownNow(); + heartbeatExecutorService.shutdown(); try { - heartbeatExecutorService.shutdown(); - heartbeatExecutorService.awaitTermination(TERMINATION_WAIT, TimeUnit.MILLISECONDS); + if (!heartbeatExecutorService.awaitTermination(TERMINATION_WAIT, TimeUnit.MILLISECONDS)) { + heartbeatExecutorService.shutdownNow(); + } } catch (InterruptedException ignore) { LOGGER.info("Stopping C2 Client's thread was interrupted but shutting down anyway the C2NifiClientService"); + heartbeatExecutorService.shutdownNow(); } }