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 a7e1d8e04c73 CAMEL-23904: Fix CamelBeanDumpTest NPE caused by
uninitialized picocli fields (#24419)
a7e1d8e04c73 is described below
commit a7e1d8e04c738a014f7814f24e91b15b899bf673
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sat Jul 4 19:41:36 2026 +0200
CAMEL-23904: Fix CamelBeanDumpTest NPE caused by uninitialized picocli
fields (#24419)
The test constructed CamelBeanDump directly without picocli, so fields
with @CommandLine.Option defaultValue annotations (sort, filter, scope)
remained null at the Java level. The scope field caused a
NullPointerException in the switch statement inside matchesScope().
Add Java field initializers matching the picocli defaults so the command
works correctly when constructed outside of picocli parsing, and set the
missing scope/nulls fields in the test.
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../apache/camel/dsl/jbang/core/commands/action/CamelBeanDump.java | 6 +++---
.../camel/dsl/jbang/core/commands/action/CamelBeanDumpTest.java | 2 ++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDump.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDump.java
index 11f68876e3c3..fd6e7bec54b9 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDump.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDump.java
@@ -72,11 +72,11 @@ public class CamelBeanDump extends ActionBaseCommand {
@CommandLine.Option(names = { "--sort" }, completionCandidates =
NameTypeCompletionCandidates.class,
description = "Sort by name or type", defaultValue =
"name")
- String sort;
+ String sort = "name";
@CommandLine.Option(names = { "--filter" },
description = "Filter beans names (use all to include
all beans)", defaultValue = "all")
- String filter;
+ String filter = "all";
@CommandLine.Option(names = { "--properties" },
description = "Show bean properties", defaultValue =
"true")
@@ -89,7 +89,7 @@ public class CamelBeanDump extends ActionBaseCommand {
@CommandLine.Option(names = { "--scope" }, completionCandidates =
ScopeCompletionCandidates.class,
description = "Filter beans by scope: all, user
(excludes Camel/Spring/Quarkus/JDK), camel, spring, quarkus",
defaultValue = "all")
- String scope;
+ String scope = "all";
@CommandLine.Option(names = { "--internal" },
description = "Include internal Camel beans",
defaultValue = "false")
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDumpTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDumpTest.java
index 8f25e546ed58..2bff8d149cfe 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDumpTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelBeanDumpTest.java
@@ -39,7 +39,9 @@ class CamelBeanDumpTest extends ActionCommandTestSupport {
// options are normally defaulted by picocli; set them as we construct
the command directly
command.filter = "all";
command.sort = "name";
+ command.scope = "all";
command.properties = true;
+ command.nulls = true;
int exit = callWithResponse(command, singleBeanResponse());