You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/07/11 06:23:24 UTC

(camel) branch fix/CAMEL-24002 created (now 11263b736879)

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

davsclaus pushed a change to branch fix/CAMEL-24002
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 11263b736879 CAMEL-24002: camel cmd send exits 0 on failure and terminated launchers cause ambiguous name

This branch includes the following new commits:

     new 11263b736879 CAMEL-24002: camel cmd send exits 0 on failure and terminated launchers cause ambiguous name

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-24002: camel cmd send exits 0 on failure and terminated launchers cause ambiguous name

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch fix/CAMEL-24002
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 11263b736879a5fbe6258010b3849b72a4782283
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jul 11 08:23:09 2026 +0200

    CAMEL-24002: camel cmd send exits 0 on failure and terminated launchers cause ambiguous name
    
    Fix two defects in camel cmd send:
    
    1. findPids in ActionBaseCommand now checks context.phase and skips
       entries with phase >= 9 (Terminated). This prevents stale launcher
       processes from exported runtimes (spring-boot/quarkus) from causing
       ambiguous name matches.
    
    2. showStatus now returns int instead of void. Returns exit code 1 on
       timeout, failed, or error status. doCall propagates this instead of
       hardcoding return 0.
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
    Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
 .../core/commands/action/ActionBaseCommand.java    | 25 +++++++++++++---------
 .../core/commands/action/CamelSendAction.java      | 12 +++++++----
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
index 8e4025432245..cf9bcea3b3c0 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
@@ -95,22 +95,27 @@ abstract class ActionBaseCommand extends CamelCommand {
                     JsonObject root = loadStatus(ph.pid());
                     // there must be a status file for the running Camel integration
                     if (root != null) {
+                        // skip terminated processes (e.g. launcher process for spring-boot/quarkus runtimes)
+                        JsonObject context = (JsonObject) root.get("context");
+                        if (context != null) {
+                            int phase = context.getIntegerOrDefault("phase", 0);
+                            if (phase >= 9) {
+                                return;
+                            }
+                        }
                         String pName = ProcessHelper.extractName(root, ph);
                         // ignore file extension, so it is easier to match by name
                         pName = FileUtil.onlyName(pName);
                         if (pName != null && !pName.isEmpty() && PatternHelper.matchPattern(pName, pattern)) {
                             pids.add(ph.pid());
-                        } else {
+                        } else if (context != null) {
                             // try camel context name
-                            JsonObject context = (JsonObject) root.get("context");
-                            if (context != null) {
-                                pName = context.getString("name");
-                                if ("CamelJBang".equals(pName)) {
-                                    pName = null;
-                                }
-                                if (pName != null && !pName.isEmpty() && PatternHelper.matchPattern(pName, pattern)) {
-                                    pids.add(ph.pid());
-                                }
+                            pName = context.getString("name");
+                            if ("CamelJBang".equals(pName)) {
+                                pName = null;
+                            }
+                            if (pName != null && !pName.isEmpty() && PatternHelper.matchPattern(pName, pattern)) {
+                                pids.add(ph.pid());
                             }
                         }
                     }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
index 9916840175df..930df8c0fa28 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
@@ -225,12 +225,10 @@ public class CamelSendAction extends ActionBaseCommand {
         this.pid = pids.get(0);
 
         Path outputFile = writeSendData();
-        showStatus(outputFile);
-
-        return 0;
+        return showStatus(outputFile);
     }
 
-    protected void showStatus(Path outputFile) throws Exception {
+    protected int showStatus(Path outputFile) throws Exception {
         try {
             // wait longer than timeout
             JsonObject jo = getJsonObject(outputFile, timeout + 10000);
@@ -278,8 +276,14 @@ public class CamelSendAction extends ActionBaseCommand {
                         printer().println(table);
                     }
                 }
+                String status = jo.getString("status");
+                if ("failed".equals(status) || "error".equals(status) || "timeout".equals(status)) {
+                    return 1;
+                }
+                return 0;
             } else {
                 printer().println("Send timeout");
+                return 1;
             }
         } finally {
             // delete output file after use