[
https://issues.apache.org/jira/browse/CAMEL-27674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27674:
--------------------------------
Fix Version/s: 4.25.0
(was: 4.24.0)
> camel-stax: a #bean ContentHandler is shared by concurrent exchanges without
> synchronization
> --------------------------------------------------------------------------------------------
>
> Key: CAMEL-27674
> URL: https://issues.apache.org/jira/browse/CAMEL-27674
> Project: Camel
> Issue Type: Bug
> Components: camel-stax
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-stax for CAMEL-23832
> (PR (commit
> https://github.com/apache/camel/commit/95860a3a49dba6fbdb046a78d91f5ed06cede71a)).
> These are separate problems of the component; the descriptions commit only
> documents the current behavior.
> h4. 1. A ContentHandler bean is shared by concurrent exchanges
> With {{stax:#myHandler}}, {{StAXEndpoint.doInit()}} resolves the bean once
> and creates {{new StAXProcessor(handler)}}. {{StAXProcessor.process()}} then
> calls {{reader.setContentHandler(this.contentHandler)}} for every exchange,
> without synchronization, and sets that same instance as the message body.
> When two messages are parsed at the same time (for example a route with
> {{threads()}}, parallel splitting or concurrent consumers), the SAX events of
> both documents go interleaved into one handler, and both exchanges get the
> same handler object as their body. The user sees mixed or wrong results from
> the handler. With a class name ({{stax:com.foo.MyHandler}}) a new instance is
> created per message, so this does not happen.
> Proposed change: either document that a {{#bean}} handler must not be used
> concurrently, or serialize the parse on the shared handler (or accept a
> prototype-scoped bean and look it up per message).
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)