Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13958

XPathBuilder threadSafe mode should also be enabled when the NodeList contains only 1 item

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.24.1
    • 3.0.0.RC2, 3.0.0
    • camel-saxon
    • None
    • Unknown

    Description

      In CAMEL-10225 the "threadSafety" property was added. But looking at the code, it is only enabled when the NodeList contains 2 or more items:

      XPathBuilder: https://github.com/apache/camel/blob/master/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathBuilder.java#L1064

              if (threadSafety && answer != null && 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;
                      if (threadSafetyNeeded) {
                          answer = new ThreadSafeNodeList(list);
                          if (LOG.isDebugEnabled()) {
                              LOG.debug("Created thread-safe result from: {} as: {}", list.getClass().getName(), answer.getClass().getName());
                          }
                      }
                  } catch (Exception e) {
                      throw ObjectHelper.wrapRuntimeCamelException(e);
                  }
              }
      

      But I get the same type of error as mentioned in CAMEL-10225 when my NodeList only contains 1 item:

      org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.io.InputStream with value <ssin>84073120992</ssin> due java.lang.NullPointerException
          at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:666)
          at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:157)
          at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:87)
          at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:61)
          at org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:124)
          at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103)
          at org.apache.camel.component.xslt.XsltEndpoint.onExchange(XsltEndpoint.java:139)
          at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)
          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
          at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
          at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
          at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
          at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:76)
          at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
          at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
          at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
          at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:76)
          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
          at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
          at org.apache.camel.processor.MulticastProcessor.doProcessParallel(MulticastProcessor.java:859)
          at org.apache.camel.processor.MulticastProcessor.access$200(MulticastProcessor.java:86)
          at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:330)
          at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:316)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at be.fgov.kszbcss.tracer.concurrent.TracerRunnable.run(TracerRunnable.java:27)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
          at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1826)
          at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1405)
          at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:79)
          at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:325)
          at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:140)
          ... 33 more
      Caused by: java.lang.NullPointerException
          at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.clearChunkValue(DeferredDocumentImpl.java:2038)
          at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.getNodeValueString(DeferredDocumentImpl.java:1149)
          at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.getNodeValueString(DeferredDocumentImpl.java:1134)
          at com.sun.org.apache.xerces.internal.dom.DeferredTextImpl.synchronizeData(DeferredTextImpl.java:96)
          at com.sun.org.apache.xerces.internal.dom.CharacterDataImpl.getData(CharacterDataImpl.java:163)
          at net.sf.saxon.dom.DOMSender.walkNode(DOMSender.java:266)
          at net.sf.saxon.dom.DOMSender.outputElement(DOMSender.java:334)
          at net.sf.saxon.dom.DOMSender.sendElement(DOMSender.java:190)
          at net.sf.saxon.dom.DOMSender.send(DOMSender.java:101)
          at net.sf.saxon.dom.DOMObjectModel.sendDOMSource(DOMObjectModel.java:282)
          at net.sf.saxon.dom.DOMObjectModel.sendSource(DOMObjectModel.java:264)
          at net.sf.saxon.event.Sender.send(Sender.java:207)
          at net.sf.saxon.jaxp.IdentityTransformer.transform(IdentityTransformer.java:366)
          at org.apache.camel.converter.jaxp.XmlConverter.toResult(XmlConverter.java:146)
          at org.apache.camel.converter.jaxp.XmlConverter.toResult(XmlConverter.java:125)
          at org.apache.camel.converter.jaxp.XmlConverter.toString(XmlConverter.java:248)
          at org.apache.camel.converter.jaxp.XmlConverter.toString(XmlConverter.java:292)
          at org.apache.camel.converter.jaxp.DomConverter.toString(DomConverter.java:105)
          at org.apache.camel.converter.jaxp.DomConverter.toString(DomConverter.java:74)
          at org.apache.camel.converter.jaxp.DomConverter.toByteArray(DomConverter.java:144)
          at org.apache.camel.converter.jaxp.DomConverter.toInputStream(DomConverter.java:139)
          at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1401)
          ... 36 more
      

      Attachments

        Activity

          People

            ramu11 Ramu
            jpraet Jimmy Praet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: