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

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


The following commit(s) were added to refs/heads/main by this push:
     new 603d2683d5 fix(console): fix NPE in AbstractJmxCommand and 
AbstractCommand.handleException. (#1967)
603d2683d5 is described below

commit 603d2683d5d928f435f6794271c9624072065987
Author: Anmol Saxena <[email protected]>
AuthorDate: Mon Jul 27 20:52:39 2026 +0530

    fix(console): fix NPE in AbstractJmxCommand and 
AbstractCommand.handleException. (#1967)
---
 .../org/apache/activemq/console/command/AbstractCommand.java   | 10 +++-------
 .../apache/activemq/console/command/AbstractJmxCommand.java    |  2 +-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git 
a/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java
 
b/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java
index a55e04ead3..9abf52039c 100644
--- 
a/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java
+++ 
b/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractCommand.java
@@ -162,13 +162,9 @@ public abstract class AbstractCommand implements Command {
     }
 
     protected void handleException(Exception exception, String serviceUrl) 
throws Exception {
-        Throwable cause = exception.getCause();
-        while (true) {
-            Throwable next = cause.getCause();
-            if (next == null) {
-                break;
-            }
-            cause = next;
+        Throwable cause = exception;
+        while (cause.getCause() != null) {
+            cause = cause.getCause();
         }
         if (cause instanceof ConnectException) {
             context.printInfo("Broker not available at: " + serviceUrl);
diff --git 
a/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java
 
b/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java
index 97e508450a..6a84b569aa 100644
--- 
a/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java
+++ 
b/activemq-console/src/main/java/org/apache/activemq/console/command/AbstractJmxCommand.java
@@ -388,7 +388,7 @@ public abstract class AbstractJmxCommand extends 
AbstractCommand {
         try {
             super.execute(tokens);
         } catch (Exception exception) {
-            handleException(exception, jmxServiceUrl.toString());
+            handleException(exception, jmxServiceUrl != null ? 
jmxServiceUrl.toString() : "local");
             return;
         }finally {
             closeJmxConnection();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to