[ 
https://issues.apache.org/jira/browse/CAMEL-27866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153232#comment-18153232
 ] 

Guillaume Nodet commented on CAMEL-27866:
-----------------------------------------

This issue is being investigated by a coding agent (on behalf of gnodet).

All four bugs have been confirmed in the current code on main:

*1. failOnNullHeader ignored in getSource()*
{{ValidatingProcessor.java:395}} checks {{isFailOnNullBody()}} even when 
validating a header. When a non-XML header value cannot be converted to Source 
and {{failOnNullBody=false}}, an empty DOM document is substituted and 
validates successfully. The correct {{isFailOnNullHeader()}} check at line 135 
only fires when content is null, not when conversion fails.

*2. Custom schemaFactory gets no resolver*
{{SchemaReader.java:160-173}}: {{getSchemaFactory()}} returns a user-provided 
factory without calling {{createSchemaFactory()}} (which is the only place the 
resource resolver is set). So {{resourceResolver}}, 
{{resourceResolverFactory}}, {{schemaLanguage}}, and ACCESS_EXTERNAL_DTD 
restrictions are all ignored for custom factories.

*3. Absolute schemaLocations get folder prepended*
{{DefaultLSResourceResolver.java:53-55}}: {{getUri()}} only excludes http/https 
URIs from prepending the folder path. Any other scheme (file:, classpath:, 
etc.) gets the folder prepended, producing broken URIs like 
{{folder/file:/absolute/schema.xsd}}.

*4. doShutdown calls super.doStop()*
{{ValidatorProducer.java:54}}: {{doShutdown()}} calls {{super.doStop()}} 
instead of {{super.doShutdown()}}.

_Note: This comment was generated by an AI coding agent and requires manual 
verification._

> camel-validator: failOnNullHeader is ignored, non-XML content passes with 
> failOnNullBody=false, a custom schemaFactory gets no resolver
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27866
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27866
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-validator
>            Reporter: Claus Ibsen
>            Assignee: Guillaume Nodet
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-validator for 
> CAMEL-23832 (commit 
> https://github.com/apache/camel/commit/1aaff12f7925110d68d6576bdc6977b75773cc4a,
>  pull request https://github.com/apache/camel/pull/31146).
> These are separate problems of the component; the descriptions change only 
> documents the current behavior.
> h4. 1. failOnNullHeader is ignored and non-XML content can pass
> {{ValidatingProcessor.getSource}} (camel-xml-jaxp) uses isFailOnNullBody() 
> also when headerName is set. With failOnNullBody=false, content that cannot 
> be converted to a Source is replaced by an empty DOM document, which 
> validates without errors, so a non-XML body passes as valid.
> Proposed change: use isFailOnNullHeader() for a header, and skip validation 
> as for a null body instead of validating a placeholder.
> h4. 2. A custom schemaFactory gets no resource resolver
> SchemaReader / ValidatorEndpoint.createProducer use a custom schemaFactory as 
> it is: resourceResolver, resourceResolverFactory and the default resolver are 
> never set, so relative xs:import/xs:include of a classpath schema fail; 
> schemaLanguage is ignored too.
> Proposed change: set the resolver on a custom factory that has none.
> h4. 3. Absolute schemaLocations get the folder prepended
> {{DefaultLSResourceResolver.getUri}} puts the folder of resourceUri in front 
> of every schemaLocation that is not http(s), so file:/... or classpath:... 
> becomes "folder/file:/..." and fails.
> Proposed change: resolve only scheme-less locations relative to the folder.
> h4. 4. doShutdown calls doStop
> {{ValidatorProducer.doShutdown}} calls super.doStop() instead of 
> super.doShutdown() (harmless today).
> Proposed change: call super.doShutdown().
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to