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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 2656643267 ARTEMIS-4375 Block console if starting server from shell
2656643267 is described below

commit 26566432678cdc10754e1d4a111e60b07a246193
Author: Clebert Suconic <[email protected]>
AuthorDate: Mon Jul 31 11:27:25 2023 -0400

    ARTEMIS-4375 Block console if starting server from shell
---
 .../src/main/java/org/apache/activemq/artemis/cli/Artemis.java |  6 +-----
 .../java/org/apache/activemq/artemis/cli/commands/Run.java     | 10 ++++++++++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index 9349fa83a6..42a29caed4 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -216,11 +216,7 @@ public class Artemis implements Runnable {
             context.out.println("Home::" + action.getBrokerHome() + ", 
Instance::" + action.getBrokerInstance());
          }
 
-         try {
-            return action.execute(context);
-         } finally {
-            action.done();
-         }
+         return action.execute(context);
       } else {
          if (userObject instanceof Runnable) {
             ((Runnable) userObject).run();
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
index bb3d926570..c032d69bc5 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.cli.Artemis;
+import org.apache.activemq.artemis.cli.Shell;
 import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
 import org.apache.activemq.artemis.cli.factory.BrokerFactory;
 import org.apache.activemq.artemis.cli.factory.jmx.ManagementFactory;
@@ -155,6 +156,15 @@ public class Run extends LockAbstract {
          return serverActivationFailed.get();
       }
 
+      if (Shell.inShell()) {
+         while (server.getServer().isStarted()) {
+            try {
+               Thread.sleep(1000);
+            } catch (InterruptedException ignored) {
+            }
+         }
+      }
+
       return new Pair<>(managementContext, server.getServer());
    }
 

Reply via email to