Skip to content

CAMEL-23904: Fix CamelBeanDumpTest NPE caused by uninitialized picocli fields#24419

Merged
davsclaus merged 1 commit into
apache:mainfrom
gnodet:camel-23904-fix-flaky-test-camelbeandumptest-in-c
Jul 4, 2026
Merged

CAMEL-23904: Fix CamelBeanDumpTest NPE caused by uninitialized picocli fields#24419
davsclaus merged 1 commit into
apache:mainfrom
gnodet:camel-23904-fix-flaky-test-camelbeandumptest-in-c

Conversation

@gnodet

@gnodet gnodet commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Claude Code on behalf of Guillaume Nodet

Fixes https://issues.apache.org/jira/browse/CAMEL-23904

CamelBeanDumpTest.testRequestsBeanDumpAndRendersBeans always fails with a NullPointerException (ERROR, not assertion FAILURE) because the test constructs CamelBeanDump directly without picocli command-line parsing.

Root cause: Picocli's @CommandLine.Option(defaultValue = "...") only takes effect during command-line parsing — it does NOT set the Java field's initial value. When the command is constructed directly (as in tests), String fields remain null. The scope field being null causes a NPE in matchesScope()'s switch statement, since Java's switch on a null String throws NPE.

Fix:

  • Add Java field initializers (= "name", = "all") to String fields in CamelBeanDump matching their picocli defaultValue, so the command works correctly when constructed outside of picocli parsing
  • Set the missing scope and nulls fields in the test to match the picocli defaults

Test plan

  • CamelBeanDumpTest passes (both test methods)
  • Module builds successfully (mvn -DskipTests install)

🤖 Generated with Claude Code

…i fields

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 <noreply@anthropic.com>
@gnodet gnodet requested review from ammachado and davsclaus July 4, 2026 17:01
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the dsl label Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core

🔬 Scalpel shadow comparison — Scalpel: 7 tested, 8 compile-only — current: 6 all tested

Maveniverse Scalpel detected 15 affected modules (current approach: 6).

⚠️ Modules only in Scalpel (9)
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage

Skip-tests mode would test 7 modules (1 direct + 6 downstream), skip tests for 8 (generated code, meta-modules)

Modules Scalpel would test (7)
  • camel-jbang-core
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
Modules with tests skipped (8)
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (15 modules)
  • Camel :: Coverage
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher
  • Camel :: Launcher :: Container

⚙️ View full build and test results

@davsclaus davsclaus marked this pull request as ready for review July 4, 2026 17:41
@davsclaus davsclaus merged commit a7e1d8e into apache:main Jul 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants