This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3793cb22ab02e404893d15c4d5157a9d5abc5e39 Author: Claus Ibsen <claus.ib...@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 6bde4d2..cea74e5 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