Repository navigation
CAMEL-27050: camel-jbang - camel catalog component reads only the first object of each component JSON - #30203
Conversation
…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>
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 5 of 726 tested, 8 compile-only — current: 5 all testedMaveniverse 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)
Modules with tests skipped (8)
💡 Manual integration tests recommended:
All tested modules (14 modules, 2m 26s total)Total reactor time: 2m 26s
Top 20 slowest modules:
|
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
oscerd
left a comment
There was a problem hiding this comment.
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
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 aComponentModel: 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.componentModelreads 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 withJsonMapper.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:camel catalog componentcamel catalog component --filter=kafkacamel catalog dataformat(unchanged)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.Catalog*Test: 177 run, 0 failures.catalog component(all 422,--filter=kafka --json, a filter that matches nothing),--camel-version=4.18.0with--runtime=spring-bootand--runtime=quarkus, andcatalog dataformatis 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