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:15:18 UTC

[camel] branch main updated (f34176b -> d3c97e6)

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

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from f34176b  Revert "CAMEL-17187: camel-xpath - @XPath annotation should never pre-compile"
     new 3c51a973 Polished
     new 3793cb2  CAMEL-17181: camel-xpath - Fixed leak when using @XPath which will keep growing pool
     new d3c97e6  Polished

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/camel/component/bean/MethodInfo.java | 16 +++++++---------
 .../org/apache/camel/language/xpath/XPathBuilder.java    |  2 +-
 .../bean/BeanWithXPathInjectionUsingHeaderValueTest.java |  7 +++++++
 3 files changed, 15 insertions(+), 10 deletions(-)

[camel] 03/03: Polished

Posted by da...@apache.org.
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 d3c97e6ca22cc0025a4098b109636722a3eeaa32
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 12 10:07:18 2021 +0100

    Polished
---
 .../src/main/java/org/apache/camel/component/bean/MethodInfo.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
index 410bfb7..c97bffc 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
@@ -301,7 +301,7 @@ public class MethodInfo {
                     if (!ServiceHelper.isStarted(dynamicRouter)) {
                         ServiceHelper.startService(dynamicRouter);
                     }
-                    // use a expression which invokes the method to be used by dynamic router
+                    // use an expression which invokes the method to be used by dynamic router
                     Expression expression = new DynamicRouterExpression(pojo);
                     expression.init(camelContext);
                     exchange.setProperty(ExchangePropertyKey.EVALUATE_EXPRESSION_RESULT, expression);

[camel] 01/03: Polished

Posted by da...@apache.org.
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 3c51a9735927be9cf89b62502d8df7fc96dc4d4c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 12 09:58:20 2021 +0100

    Polished
---
 .../java/org/apache/camel/component/bean/MethodInfo.java   | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
index 811292f..410bfb7 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
@@ -394,7 +394,7 @@ public class MethodInfo {
             old = exchange.getIn();
         }
 
-        // create a new message container so we do not drag specialized message objects along
+        // create a new message container, so we do not drag specialized message objects along
         // but that is only needed if the old message is a specialized message
         boolean copyNeeded = !(old.getClass().equals(DefaultMessage.class));
 
@@ -635,15 +635,13 @@ public class MethodInfo {
         /**
          * Evaluate using parameter values where the values can be provided in the method name syntax.
          * <p/>
-         * This methods returns accordingly:
+         * This method returns accordingly:
          * <ul>
          * <li><tt>null</tt> - if not a parameter value</li>
          * <li><tt>Void.TYPE</tt> - if an explicit null, forcing Camel to pass in <tt>null</tt> for that given
          * parameter</li>
          * <li>a non <tt>null</tt> value - if the parameter was a parameter value, and to be used</li>
          * </ul>
-         *
-         * @since 2.9
          */
         private Object evaluateParameterValue(Exchange exchange, int index, Object parameterValue, Class<?> parameterType) {
             Object answer = null;
@@ -659,7 +657,7 @@ public class MethodInfo {
                     // as this method is only for evaluating parameter values
                     Boolean isClass = BeanHelper.isAssignableToExpectedType(exchange.getContext().getClassResolver(), exp,
                             parameterType);
-                    // the method will return a non null value if exp is a class
+                    // the method will return a non-null value if exp is a class
                     if (isClass != null) {
                         return null;
                     }
@@ -696,9 +694,9 @@ public class MethodInfo {
                         valid = parameterValue instanceof String;
                         if (!valid) {
                             // the parameter value was not already valid, but since the simple language have evaluated the expression
-                            // which may change the parameterValue, so we have to check it again to see if its now valid
+                            // which may change the parameterValue, so we have to check it again to see if it is now valid
                             exp = exchange.getContext().getTypeConverter().tryConvertTo(String.class, parameterValue);
-                            // re validate if the parameter was not valid the first time
+                            // re-validate if the parameter was not valid the first time
                             valid = BeanHelper.isValidParameterValue(exp);
                         }
                     }
@@ -710,7 +708,7 @@ public class MethodInfo {
                         parameterValue = StringHelper.removeLeadingAndEndingQuotes((String) parameterValue);
                     }
                     try {
-                        // its a valid parameter value, so convert it to the expected type of the parameter
+                        // it is a valid parameter value, so convert it to the expected type of the parameter
                         answer = exchange.getContext().getTypeConverter().mandatoryConvertTo(parameterType, exchange,
                                 parameterValue);
                         if (LOG.isTraceEnabled()) {

[camel] 02/03: CAMEL-17181: camel-xpath - Fixed leak when using @XPath which will keep growing pool

Posted by da...@apache.org.
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 <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 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