Claus Ibsen created CAMEL-27653:
-----------------------------------
Summary: camel-json-validator: contentCache ignored, null schema
to error handler, unused option
Key: CAMEL-27653
URL: https://issues.apache.org/jira/browse/CAMEL-27653
Project: Camel
Issue Type: Bug
Components: camel-jsonvalidator
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-json-validator for
CAMEL-23832 (commit
https://github.com/apache/camel/commit/d565b4e66fb4edec92597a51fff7c1538804ae09).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. contentCache has no effect
{{JsonValidatorEndpoint.onExchange()}} loads the schema once with
{{getOrCreateSchema()}} and keeps it in the {{schema}} field, whatever the
value of {{contentCache}}. {{DefaultJsonUriSchemaLoader.createSchema()}} reads
the resource with {{ResourceHelper.resolveMandatoryResourceAsInputStream()}},
not with {{ResourceEndpoint.getResourceAsInputStream()}}, so the cache of
{{ResourceEndpoint}} is never used either.
A user who sets {{contentCache=false}} to pick up a changed schema file still
gets the old schema; only the JMX operation {{clearContentCache}} reloads it.
Proposed change: with {{contentCache=false}}, load the schema for each message
(or document the option as not used and hide it).
h4. 2. The error handler can get a null schema
{{JsonValidatorEndpoint.onExchange()}} takes a local copy of the schema
({{localSchema}}) for the validation, but passes the {{schema}} field to
{{errorHandler.handleErrors(exchange, schema, ...)}}. When
{{clearContentCache()}} runs at the same time (JMX), the field is null and the
handler, and the {{JsonValidationException}} it throws, get a null schema.
Proposed change: pass {{localSchema}} to the error handler.
h4. 3. allowContextMapAll is listed but not used
The option is inherited from {{ResourceEndpoint}} and shows in the endpoint
options, but the component has no template context map and never reads it.
Proposed change: hide the option for this component, or say in its text that it
is not used.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)