You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/11/12 09:17:06 UTC

[camel] branch camel-3.7.x updated: CAMEL-17181: camel-xpath - Fixed leak when using @XPath which will keep growing pool

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.7.x by this push:
     new 4ca7288  CAMEL-17181: camel-xpath - Fixed leak when using @XPath which will keep growing pool
4ca7288 is described below

commit 4ca7288dcae2f6e7be2a947afb757e672d0247c9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 12 10:07:10 2021 +0100

    CAMEL-17181: camel-xpath - Fixed leak when using @XPath which will keep growing pool
---
 .../main/java/org/apache/camel/language/xpath/XPathBuilder.java    | 2 +-
 .../component/bean/BeanWithXPathInjectionUsingHeaderValueTest.java | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathBuilder.java b/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathBuilder.java
index 7fabaed..af1453b 100644
--- a/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathBuilder.java
+++ b/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathBuilder.java
@@ -163,7 +163,7 @@ public class XPathBuilder extends ServiceSupport
 
     @Override
     public void init(CamelContext context) {
-        if (preCompile) {
+        if (preCompile && pool.isEmpty()) {
             LOG.trace("PreCompiling new XPathExpression and adding to pool during initialization");
             try {
                 XPathExpression xpathExpression = createXPathExpression();
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithXPathInjectionUsingHeaderValueTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithXPathInjectionUsingHeaderValueTest.java
index b688a5c..fd1030c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithXPathInjectionUsingHeaderValueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithXPathInjectionUsingHeaderValueTest.java
@@ -39,6 +39,13 @@ public class BeanWithXPathInjectionUsingHeaderValueTest extends ContextTestSuppo
         assertEquals("OK", myBean.response, "bean response:  " + myBean);
         assertEquals("Alan", myBean.userName, "bean userName: " + myBean);
         assertEquals("26/08/2012", myBean.date, "bean date:  " + myBean);
+
+        template.sendBodyAndHeader("bean:myBean", "<response>OK</response>", "invoiceDetails",
+                "<invoice><person><name>Jack</name><date>27/08/2012</date></person></invoice>");
+
+        assertEquals("OK", myBean.response, "bean response:  " + myBean);
+        assertEquals("Jack", myBean.userName, "bean userName: " + myBean);
+        assertEquals("27/08/2012", myBean.date, "bean date:  " + myBean);
     }
 
     @Override