[ 
https://issues.apache.org/jira/browse/CAMEL-27838?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-27838:
--------------------------------
    Description: 
Found while improving the option descriptions of camel-mvel for CAMEL-23832 
(commit 
https://github.com/apache/camel/commit/d706f57a8fb08065b46a08a0acbc00620fd890d7,
 pull request https://github.com/apache/camel/pull/31142).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. A race in the compiled-template cache
{{MvelEndpoint.onExchange}} sets this.template before this.compiled = 
TemplateCompiler.compileTemplate(...). A concurrent exchange in between sees 
the same text and uses this.compiled, which is null for the first exchanges 
(NullPointerException in TemplateRuntime.execute) or the old template after a 
change.
Proposed change: keep text and compiled template in one immutable holder in a 
single volatile field, or set compiled before template under a lock.

h4. 2. The resource URI header builds a broken endpoint URI
{{MvelEndpoint.findOrCreateEndpoint}} uses uri.replace(getResourceUri(), 
newResourceUri), which replaces every occurrence in the URI, also inside option 
values.
Proposed change: rebuild the URI from scheme, new resource and query.


_Claude Code on behalf of davsclaus_

  was:
Found while improving the option descriptions of camel-mvel for CAMEL-23832 
(pull request https://github.com/apache/camel/pull/31142).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. A race in the compiled-template cache
{{MvelEndpoint.onExchange}} sets this.template before this.compiled = 
TemplateCompiler.compileTemplate(...). A concurrent exchange in between sees 
the same text and uses this.compiled, which is null for the first exchanges 
(NullPointerException in TemplateRuntime.execute) or the old template after a 
change.
Proposed change: keep text and compiled template in one immutable holder in a 
single volatile field, or set compiled before template under a lock.

h4. 2. The resource URI header builds a broken endpoint URI
{{MvelEndpoint.findOrCreateEndpoint}} uses uri.replace(getResourceUri(), 
newResourceUri), which replaces every occurrence in the URI, also inside option 
values.
Proposed change: rebuild the URI from scheme, new resource and query.


_Claude Code on behalf of davsclaus_


> camel-mvel: a race in the compiled-template cache gives NullPointerException
> ----------------------------------------------------------------------------
>
>                 Key: CAMEL-27838
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27838
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-mvel for CAMEL-23832 
> (commit 
> https://github.com/apache/camel/commit/d706f57a8fb08065b46a08a0acbc00620fd890d7,
>  pull request https://github.com/apache/camel/pull/31142).
> These are separate problems of the component; the descriptions change only 
> documents the current behavior.
> h4. 1. A race in the compiled-template cache
> {{MvelEndpoint.onExchange}} sets this.template before this.compiled = 
> TemplateCompiler.compileTemplate(...). A concurrent exchange in between sees 
> the same text and uses this.compiled, which is null for the first exchanges 
> (NullPointerException in TemplateRuntime.execute) or the old template after a 
> change.
> Proposed change: keep text and compiled template in one immutable holder in a 
> single volatile field, or set compiled before template under a lock.
> h4. 2. The resource URI header builds a broken endpoint URI
> {{MvelEndpoint.findOrCreateEndpoint}} uses uri.replace(getResourceUri(), 
> newResourceUri), which replaces every occurrence in the URI, also inside 
> option values.
> Proposed change: rebuild the URI from scheme, new resource and query.
> _Claude Code on behalf of davsclaus_



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

Reply via email to