camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piotr Bzdyl (JIRA)" <>
Subject [jira] [Commented] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
Date Mon, 30 Jul 2012 14:19:35 GMT


Piotr Bzdyl commented on CAMEL-3813:

In my case the problem was with using @XPath annotation on the bean method argument. When
such annotation is used, BeanProcessor uses a copy of the original exchange and that copy
is provided to the XPathBuilder instance implementing @XPath annotated argument extraction.
For that exchange copy its XPathBuilderCompletion is not executed so the solution provided
in this issue doesn't fix this.

What's worse, BeanExpression.evaluate(Exchange exchange) creates a holder instance for each
invocation and a new XPathBuilder instance is created (through new ConstantHolder -> new
BeanInfo -> ... -> BeanInfo.createParameterUnmarshalExpressionForAnnotation -> XPathAnnotationExpressionFactory.createExpression)
so for each such evaluate calls two XPathBuilder's thread locals are leaking.

[CAMEL-5392] optimizes BeanExpression.evaluate by caching the holder instance and thus prevents
the leakage. However, the thread locals are not eligible for GC until another exchange processing
in the same thread overrides them with new values as the completion is not being called on
the exchange copy. As a result those thread locals objects might be retained much longer than
the exchange life.
> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>                 Key: CAMEL-3813
>                 URL:
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>            Assignee: Claus Ibsen
>            Priority: Minor
>              Labels: xpath
>             Fix For: 2.8.0
>         Attachments: bug_reproduction.patch
> XPathBuilder doesn't clear ThreadLocal with exchange (and variableResolver) after evaluation.
In such case reference to current exchange (and body, headers, properties, etc.) remains in
Thread until current thread dies or evaluates new exchange with the same XPathBuilder instance.
> The result of this is that each thread can contain references to multiple exchanges (up
to the number of xpaths in camel context), that can't be collected by GC.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message