steve-cdl opened a new issue, #6947:
URL: https://github.com/apache/camel-quarkus/issues/6947

   ### Bug description
   
   Hi,
   
   We are using Camel 4.9.0 and Quarkus 3.17.7.
   
   Our app receives an XML input and within that XML is a set of codes.
   We need to run XSLT transforms for each one of these codes, in parallel.
   
   To do this we are using <split> with xtokenize (although tokenize and XPATH 
also show this issue).
   
   While doing this, we have found that if anything replaces the body during 
the split, this new body is picked up by the other splits / threads, causing 
duplication / errors.
   
   This does not appear to occur if body is never changed.
   
   For example using the following input - 
   
   ```
   <Books>
       <Book code="AA"/>
       <Book code="BB"/>
   </Books>
   ```
   
   And the following route - 
   
   ```
   <route streamCache="false">
           <from uri="direct:xtokenize-main-route"/>
           <split parallelProcessing="true">
               <xtokenize>//Books/Book</xtokenize>
               <log loggingLevel="INFO" logName="xml" message="body is: 
${body}"/>
           </split>
   </route>
   ```
   
   Would result in the correct body being logged within the split.
   `"body is: <Book code="AA"/>"`
   `"body is: <Book code="BB"/>"`
   
   However, if you replace body within the split, for example running an XSLT, 
the body of the 2nd thread/split will become the amended body of thread 1.
   
   For example - 
   
   ```
   <route streamCache="false">
           <from uri="direct:xtokenize-main-route"/>
           <split parallelProcessing="true">
               <xtokenize>//Books/Book</xtokenize>
               <toD uri="xslt-saxon:file://path/to/example/stylesheet.xslt"/>
               <log loggingLevel="INFO" logName="xml" message="body is: 
${body}"/>
           </split>
   </route>
   ```
   
   Thread 1 - 
   `"body is:  <Book code="AA"/>"`
   XSLT is ran. Output of XSLT is `<hello>world</hello>`
   
   Thread 2 
   `"body is: <hello>world</hello>"`
   Whereas Body should be the 2nd book / thread (`<Book code="BB"/>`)
   
   When posting the same test again, the correct outcome occurs -
   
   Thread 1 - 
   `"body is:  <Book code="AA"/>"`
   XSLT is ran. Output of XSLT is `<hello>World</hello>`
   
   Thread 2 - 
   `"body is:  <Book code="BB"/>"`
   XSLT is ran. Output of XSLT is `<hello>World</hello>`
   
   Adding an extra "book" / reason to split will trigger the issue again, for 
the new 'book'.
   
   So this appears to happen the first time a new reason to split (book for 
example) is used.
   (changing other parts of the input doesn't produce this behaviour, only 
adding additional 'books' / nodes that need to be split)
   
   When testing this with one input for the split (so 1 book) the body is blank.
   When reposting this test, the body is as expected.
   
   We also found that turning streamCache to true produced this error, 
regardless of whether body was being changed or not.
   
   This also doesn't appear to apply to just XSLT either. Changing the body in 
anyway during the split seems to produce this issue.
   
   So to summarise.
   
   When using split.
   If the ${body} is ever changed during the split (or streamCache=true) the 
body provided to the following threads of the split, is replaced with the 
amended body from the first thread.
   
   thread 1 = body is as expected
   thread 2 = body is not as expected (either blank or amended body from thread 
1)
   
   This only occurs on the first test.
   Reposting the same payload gives expected results.
   
   Hopefully this is enough information for somebody to reproduce the bug.
   If you need anything else, please let me know.
   Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to