Skip to content

CAMEL-27050: camel-jbang - camel catalog component reads only the first object of each component JSON - #30203

Merged
davsclaus merged 1 commit into
mainfrom
CAMEL-27050-catalog-component-header
Nov 16, 2026
Merged

davsclaus merged 1 commit into
mainfrom
CAMEL-27050-catalog-component-header

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

CAMEL-27050

camel catalog component (with or without --filter) took about 420 ms, three times as long as the other short commands. For each of the 422 components it read the whole model JSON from the catalog and parsed it into a ComponentModel: 14 MB of JSON, as the options and headers are most of each file. The list shows only the name, title, support level, since, description, label, native and Maven coordinates, which are all in the first object of the file ("component").

Change

CatalogModelHeader.componentModel reads each component JSON only up to the end of its "component" object (strings, escapes and nested objects are skipped correctly), and builds the model from that object with JsonMapper.generateComponentModel, so the getters behave the same. The JSON is read through the version manager and runtime provider of the catalog, so it also works for --camel-version, Spring Boot and Quarkus. When the JSON is not in the catalog (a component added to it at runtime) or does not start with that object, the whole model is read from the catalog as before.

Only components: the models of data formats, languages and others are a few KB, and reading the first object before parsing it cost 6-10 ms more than parsing the whole small file (measured), so those lists stay as they are.

Measured

JDK 25, macOS (Apple M4 Pro), through camel.sh (with its CDS archive), median of 15 runs:

command main this PR
camel catalog component 441 ms 223 ms
camel catalog component --filter=kafka 417 ms 215 ms
camel catalog dataformat (unchanged) 174 ms 178 ms

Tests

  • CatalogModelHeaderTest (new): the first object only; braces and escaped quotes in strings; another first key, a longer key, a value that is not an object, a JSON that ends first; and for every component of the catalog, every field the list shows is the same as from the whole model.
  • camel-jbang-core Catalog*Test: 177 run, 0 failures.
  • Distribution: the output of catalog component (all 422, --filter=kafka --json, a filter that matches nothing), --camel-version=4.18.0 with --runtime=spring-boot and --runtime=quarkus, and catalog dataformat is byte for byte the same as on main.

Related: #30199 (CAMEL-27045) and #30201 (CAMEL-27048), the other startup work for the short commands.

Claude Code on behalf of davsclaus

🤖 Generated with Claude Code

https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS

…st object of each component JSON

camel catalog component read the whole model JSON of each of the 422
components (14 MB, most of it options and headers) to show a few fields
that are all in the first object of the file ("component"). It now reads
each JSON up to the end of that object, through the version manager of
the catalog, and reads the whole model as before when the JSON is not
in the catalog or does not start with that object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

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

🔬 Scalpel shadow comparison — Scalpel: 5 of 726 tested, 8 compile-only — current: 5 all tested

Maveniverse Scalpel detected 5 affected modules (current approach: 5).

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

Modules Scalpel would test (5)
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-jbang-core
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
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: 2 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 (14 modules, 2m 26s total)

Total reactor time: 2m 26s

Module Duration Status
Camel :: JBang :: Plugin :: TUI 43.1s SUCCESS
Camel :: JBang :: MCP 40.0s SUCCESS
Camel :: JBang :: Plugin :: Validate 22.2s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 10.9s SUCCESS
Camel :: JBang :: Plugin :: Testing 10.7s SUCCESS
Camel :: JBang :: Plugin :: Generate 6.9s SUCCESS
Camel :: Coverage 4.1s SUCCESS
Camel :: JBang :: Plugin :: Edit 3.0s SUCCESS
Camel :: JBang :: Plugin :: MCP 2.5s SUCCESS
Camel :: JBang :: Main 1.4s SUCCESS
Camel :: JBang :: Integration tests 0.9s SUCCESS
Camel :: Launcher :: Container 0.6s SUCCESS
Camel :: JBang :: Core n/a
Camel :: Launcher n/a

Top 20 slowest modules:

  • Camel :: JBang :: Plugin :: TUI (43.1s)
  • Camel :: JBang :: MCP (40.0s)
  • Camel :: JBang :: Plugin :: Validate (22.2s)
  • Camel :: JBang :: Plugin :: Kubernetes (10.9s)
  • Camel :: JBang :: Plugin :: Testing (10.7s)
  • Camel :: JBang :: Plugin :: Generate (6.9s)
  • Camel :: Coverage (4.1s)
  • Camel :: JBang :: Plugin :: Edit (3.0s)
  • Camel :: JBang :: Plugin :: MCP (2.5s)
  • Camel :: JBang :: Main (1.4s)
  • Camel :: JBang :: Integration tests (0.9s)
  • Camel :: Launcher :: Container (0.6s)

⚙️ View full build and test results

@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 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.

@davsclaus davsclaus self-assigned this Nov 16, 2026
@davsclaus
davsclaus merged commit dbcb2f2 into main Nov 16, 2026
6 checks passed
@davsclaus
davsclaus deleted the CAMEL-27050-catalog-component-header branch November 16, 2026 16:02

@oscerd oscerd left a comment

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.

Good optimization, and the fallback keeps it correct for the cases that do not fit.

camel catalog component was reading and parsing the full model JSON for all 422 components, 14 MB, when the list only prints what lives in the first object (name, title, support level, since, description, label, native, Maven coordinates). The options and headers that make up most of each file were parsed and thrown away. Reading just the first object through CatalogModelHeader is the right scope for what the list shows.

The correctness hinge is the fallback, and it is handled: when the JSON is not in the catalog (a component added at runtime) or does not start with that object, componentModel returns null and the caller falls back to the full read, so a non-standard or runtime-contributed component is still listed rather than dropped. That is the detail that makes this safe to do by position.

The "no lambdas or method references here" note is a fair call in this specific spot: on a command whose whole job is to be fast to start, the one-time metafactory cost of the first lambda is on the same order as what the faster parse saves, so avoiding it here is consistent rather than contradictory with using lazy suppliers elsewhere where they defer real class loading. Nicely judged.

Claude Code on behalf of oscerd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dsl enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants