Skip to content

Fix camel-jbang logging file appender and jbang java version option#22337

Merged
Croway merged 2 commits intomainfrom
fix/jbang-it-logging-and-java-version
Mar 30, 2026
Merged

Fix camel-jbang logging file appender and jbang java version option#22337
Croway merged 2 commits intomainfrom
fix/jbang-it-logging-and-java-version

Conversation

@Croway
Copy link
Copy Markdown
Contributor

@Croway Croway commented Mar 30, 2026

Summary

  • Add missing file appender to log4j2-no-color.properties — Since CAMEL-23226 changed loggingColor to auto-detect via EnvironmentHelper.isColorEnabled(), non-TTY environments (Docker containers, CI) use the no-color log config, which lacked the file appender. Logs went only to console, never to ~/.camel/<pid>.log, causing camel log to return empty and 38+ IT tests to timeout after 5 minutes.
  • Fix jbang --java-version--java — jbang does not recognize --java-version; the correct flag is --java. This caused 3 IT tests to fail when running with --camel-version pointing to older Camel versions.

Root cause analysis

Timeout failures (38 tests): Regression introduced by 3adff4a7fd4 (CAMEL-23226) which changed loggingColor default from true to EnvironmentHelper.isColorEnabled(). In Docker containers without TTY, this returns false, selecting log4j2-no-color.properties which had no file appender — unlike log4j2.properties which logs to both console and file.

--java-version failures (3 tests): Bug in c00319b34c6 (CAMEL-23235) which passed --java-version=21 to jbang, but jbang's actual option is --java.

Test plan

  • Ran RunCommandITCase#initAndRunTest locally — was timing out, now passes in ~10s
  • Ran RunCommandITCase#runSpecificVersionTest locally — was failing with Unknown option, now passes
  • Ran VersionCommandITCase#executeAfterVersionSetTest locally — was failing, now passes
  • All 4 tests: 0 failures (down from 41 failures in CI)

🤖 Generated with Claude Code

Two fixes for the Camel JBang IT test failures:

1. Add missing file appender to log4j2-no-color.properties. The
   no-color logging config lacked the file appender that log4j2.properties
   has. Since CAMEL-23226 changed loggingColor to auto-detect based on
   environment (EnvironmentHelper.isColorEnabled()), non-TTY environments
   like Docker containers now use the no-color config, which wrote logs
   only to console and never to ~/.camel/<pid>.log. This caused camel log
   to always return empty output, failing 38+ IT tests with timeouts.

2. Fix jbang --java-version option: use --java instead. The
   --java-version flag is not recognized by jbang. The correct flag to
   set the Java version is --java. This caused failures when running
   with --camel-version pointing to older Camel versions.
@github-actions
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 build-all, build-dependents, 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.

@Croway
Copy link
Copy Markdown
Contributor Author

Croway commented Mar 30, 2026

@smongiar @gnodet fyi

@github-actions github-actions bot added the dsl label Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core
  • dsl/camel-jbang/camel-jbang-plugin-kubernetes
All tested modules (26 modules)
  • Camel :: Coverage
  • Camel :: Coverage [pom]
  • Camel :: JBang :: Core
  • Camel :: JBang :: Core [jar]
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: Integration tests [jar]
  • Camel :: JBang :: MCP
  • Camel :: JBang :: MCP [jar]
  • Camel :: JBang :: Main
  • Camel :: JBang :: Main [jar]
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Edit [jar]
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Generate [jar]
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: Kubernetes [jar]
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: Route Parser [jar]
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Testing [jar]
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JBang :: Plugin :: Validate [jar]
  • Camel :: Launcher
  • Camel :: Launcher [jar]
  • Camel :: Launcher :: Container
  • Camel :: Launcher :: Container [pom]


if (javaVersion != null) {
jbangArgs.add("--java-version=" + javaVersion);
jbangArgs.add("--java=" + javaVersion);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change the --java-version parameter too which was added in the breaking commit in order to keep consistency between commands? c00319b

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, in this case, --java is the JBang one, but I guess I can add an alias (for backward compatibility) to the Camel JBang Run and Export, wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should work but worth to be tried, including when using "cross-versions" of Camel and Camel Jbang (which can be potentially used in from command-line and from VS Code integrations) because it reminds me simlar issues than afb0b1a when there was a renaming of property

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I just pushed a new commit that handle cross-version compatibility.. I actually never thought about cross-versions compatibility... well.. it is scary :D but I do think that most of the user stick on the latest Camel JBang version

@Croway
Copy link
Copy Markdown
Contributor Author

Croway commented Mar 30, 2026

@apupier @smongiar in the latest commit I've added the --java alias

@Croway Croway force-pushed the fix/jbang-it-logging-and-java-version branch from cad250e to 62dc355 Compare March 30, 2026 12:46
Keep --java-version for backward compatibility and add --java as an
alias in Run, ExportBaseCommand, and KubernetesRun commands.

Strip --java/--java-version from cmds in runCamelVersion() to avoid
passing an unrecognized option to older Camel versions that only know
--java-version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Croway Croway force-pushed the fix/jbang-it-logging-and-java-version branch from 62dc355 to 7362280 Compare March 30, 2026 14:38
Copy link
Copy Markdown
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix for two clear regressions. Root cause analysis in the PR description is excellent.

A few observations:

Generated files need regeneration — The picocli annotation changes (adding --java alias) need the generated metadata and docs updated. Currently camel-jbang-commands-metadata.json still shows only --java-version for the export/sbom commands, and the generated docs in docs/user-manual/modules/ROOT/pages/jbang-commands/ also only reference --java-version. The CI "uncommitted changes" check will likely flag this. Run:

mvn install -B -pl dsl/camel-jbang/camel-jbang-core -DskipTests

and commit the regenerated files.

Pre-existing: color config's file appender uses ANSI patterns — Not introduced by this PR, but worth noting: log4j2.properties writes %style{...} / %highlight{...} patterns to the file appender, so ~/.camel/{pid}.log ends up with ANSI escape codes. The no-color fix correctly uses plain patterns for the file, which is actually better behavior.

Claude Code on behalf of Guillaume Nodet

@Croway Croway merged commit a5a68ff into main Mar 30, 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.

4 participants