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 2019/09/30 08:43:54 UTC

[camel] branch master updated: CAMEL-13958: XPathBuilder threadSafe mode should also be enabled when the NodeList contains only 1 item

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

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


The following commit(s) were added to refs/heads/master by this push:
     new cae5b47  CAMEL-13958: XPathBuilder threadSafe mode should also be enabled when the NodeList contains only 1 item
cae5b47 is described below

commit cae5b47fd8eb11a6fa2c1d4fd825e3e25f519b89
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Sep 30 10:38:29 2019 +0200

    CAMEL-13958: XPathBuilder threadSafe mode should also be enabled when the NodeList contains only 1 item
---
 .../java/org/apache/camel/language/xpath/XPathBuilder.java     | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

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 e25c0ff..27cc0b3 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
@@ -1061,15 +1061,13 @@ public class XPathBuilder extends ServiceSupport implements CamelContextAware, E
             IOHelper.close(is);
         }
 
-        if (threadSafety && answer != null && answer instanceof NodeList) {
+        if (threadSafety && answer instanceof NodeList) {
             try {
                 NodeList list = (NodeList)answer;
 
-                // when the result is NodeList and it has 2+ elements then its
-                // not thread-safe to use concurrently
-                // and we need to clone each node and build a thread-safe list
-                // to be used instead
-                boolean threadSafetyNeeded = list.getLength() >= 2;
+                // when the result is NodeList and it has 1 or more elements then its not thread-safe to use concurrently
+                // and we need to clone each node and build a thread-safe list to be used instead
+                boolean threadSafetyNeeded = list.getLength() >= 1;
                 if (threadSafetyNeeded) {
                     answer = new ThreadSafeNodeList(list);
                     if (LOG.isDebugEnabled()) {