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 4eef3816d57 CAMEL-22220: camel-jbang - Fix NPE in get variable command
4eef3816d57 is described below
commit 4eef3816d5760713699c5d6b6e345dba882e7169
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 4 16:15:56 2025 +0200
CAMEL-22220: camel-jbang - Fix NPE in get variable command
---
.../jbang/core/commands/process/ListVariable.java | 26 ++++++++++++----------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListVariable.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListVariable.java
index 1619c2167e2..f4936368d93 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListVariable.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListVariable.java
@@ -81,17 +81,19 @@ public class ListVariable extends ProcessWatchCommand {
row.pid = Long.toString(ph.pid());
JsonObject jv = (JsonObject) root.get("variables");
- for (String id : jv.keySet()) {
- JsonArray arr = jv.getCollection(id);
- if (arr != null) {
- for (int i = 0; i < arr.size(); i++) {
- row = row.copy();
- JsonObject jo = (JsonObject) arr.get(i);
- row.id = id;
- row.key = jo.getString("key");
- row.type = jo.getString("type");
- row.value = jo.get("value");
- rows.add(row);
+ if (jv != null) {
+ for (String id : jv.keySet()) {
+ JsonArray arr = jv.getCollection(id);
+ if (arr != null) {
+ for (int i = 0; i < arr.size(); i++) {
+ row = row.copy();
+ JsonObject jo = (JsonObject)
arr.get(i);
+ row.id = id;
+ row.key = jo.getString("key");
+ row.type = jo.getString("type");
+ row.value = jo.get("value");
+ rows.add(row);
+ }
}
}
}
@@ -106,7 +108,7 @@ public class ListVariable extends ProcessWatchCommand {
new
Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
new
Column().header("NAME").dataAlign(HorizontalAlign.LEFT).maxWidth(30,
OverflowBehaviour.ELLIPSIS_RIGHT)
.with(r -> r.name),
- new
Column().header("REPOSITORY").headerAlign(HorizontalAlign.CENTER).with(r ->
r.id),
+ new
Column().header("REPO").headerAlign(HorizontalAlign.CENTER).with(r -> r.id),
new
Column().header("TYPE").headerAlign(HorizontalAlign.CENTER)
.maxWidth(40,
OverflowBehaviour.ELLIPSIS_LEFT).with(r -> r.type),
new
Column().header("KEY").dataAlign(HorizontalAlign.LEFT).maxWidth(50,
OverflowBehaviour.ELLIPSIS_RIGHT)