You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Marcin Kolda (JIRA)" <ji...@apache.org> on 2011/03/28 17:48:05 UTC

[jira] [Created] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
---------------------------------------------------------------------

                 Key: CAMEL-3813
                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.7.0
            Reporter: Marcin Kolda


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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3813:
-------------------------------


Thats by design

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>              Labels: xpath
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012411#comment-13012411 ] 

Claus Ibsen commented on CAMEL-3813:
------------------------------------

Marcin I have committed an improvement in rev 1086530
Do you mind giving that a test in your system?

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>            Priority: Minor
>              Labels: xpath
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3813:
-------------------------------

      Priority: Minor  (was: Major)
    Issue Type: Improvement  (was: Bug)

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>            Priority: Minor
>              Labels: xpath
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Marcin Kolda (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012371#comment-13012371 ] 

Marcin Kolda commented on CAMEL-3813:
-------------------------------------

Yes, ThreadLocal should be cleared. We noticed huge improvement of GC under heavy load after using workaround for that. It's even worse when you use fixed thread pool (e.g. seda component) and/or Saxon for XSLT which contains WeakHashMap, in which key is a Document (body of exchange).

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>            Priority: Minor
>              Labels: xpath
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Marcin Kolda (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012874#comment-13012874 ] 

Marcin Kolda commented on CAMEL-3813:
-------------------------------------

I prepared such testcase to verify that ThreadLocal is empty right after evaluation (without using UnitOfWork and Synchronization). It's done this way in {{public <T> T evaluate(CamelContext context, Object body, Class<T> type)}} and few other methods in XPathBuilder. Such solution would be just simpler for me.

I tested this with our real system previously and that still didn't work for us. I will have to digg into this when I'll have more time. I'll let you know if I find anything.

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-3813.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.8.0
         Assignee: Claus Ibsen

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012526#comment-13012526 ] 

Claus Ibsen commented on CAMEL-3813:
------------------------------------

Your unit test is flawed as it doesn't handle the unit of work which will ensure the thread locals get cleared when the exchange is done being processed. 

So check out a Camel route instead, and check in your system for real.

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>            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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Issue Comment Edited] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012118#comment-13012118 ] 

Claus Ibsen edited comment on CAMEL-3813 at 3/28/11 4:10 PM:
-------------------------------------------------------------

Thats was actually by design. But maybe there is a need to ensure the thread locals is cleared when the exchange is done. 

      was (Author: davsclaus):
    Thats by design
  
> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>              Labels: xpath
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CAMEL-3813) XPathBuilder doesn't clear ThreadLocal with exchange after evaluation

Posted by "Marcin Kolda (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-3813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcin Kolda updated CAMEL-3813:
--------------------------------

    Attachment: bug_reproduction.patch

Unfortunately fix doesn't work for us. Threads are still containing references.

I attached simple patch for reproducing this bug. It simply verifies if main thread contains reference to exchange.

> XPathBuilder doesn't clear ThreadLocal with exchange after evaluation
> ---------------------------------------------------------------------
>
>                 Key: CAMEL-3813
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3813
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Marcin Kolda
>            Priority: Minor
>              Labels: xpath
>         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.
For more information on JIRA, see: http://www.atlassian.com/software/jira