This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 48f4291078ed CAMEL-24002: Fix cmd send exit code and terminated
launcher ambiguity
48f4291078ed is described below
commit 48f4291078ed5c2c378c07f490410c73d365246f
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Jul 11 19:37:48 2026 +0200
CAMEL-24002: Fix cmd send exit code and terminated launcher ambiguity
Fix two defects in camel cmd send:
1. findPids now checks context.phase and skips entries with phase >= 9
(Terminated), preventing stale launcher processes from exported
runtimes (spring-boot/quarkus) from causing ambiguous name matches.
2. showStatus now returns int instead of void, returning exit code 1
on timeout, failed, or error status. doCall propagates this instead
of hardcoding return 0.
Closes #24596
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
.../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