Rik van Ballegooijen created CAMEL-20429:
--------------------------------------------

             Summary: setBody clears/invalidates streamcache still being used 
in header/property
                 Key: CAMEL-20429
                 URL: https://issues.apache.org/jira/browse/CAMEL-20429
             Project: Camel
          Issue Type: Bug
          Components: came-core
    Affects Versions: 4.0.3
            Reporter: Rik van Ballegooijen


While upgrading from camel 3 to 4 we ran into a stream cache related issue. An 
input stream containing the content of a HTML file is 
emptied/closed/invalidated after setting the exchange body to something 
different, even though the input stream is still in use, for example in a 
header.
{code:java}
<setHeader name="CamelThymeleafTemplate">
    <simple>${exchangeProperty.templateContents}</simple>
</setHeader>
<log message="CamelThymeleafTemplate after header set: 
${headers.CamelThymeleafTemplate}" />
<setBody>
    <exchangeProperty>templateData</exchangeProperty>
</setBody>
<log message="CamelThymeleafTemplate before thymeleaf endpoint: 
${headers.CamelThymeleafTemplate}" /> {code}
In the example above the first log statement will print the content of the HTML 
file, the 2nd log statement will print an empty header. No errors are thrown.

As a workaround, changing the type to a String fixes the issue:
{code:java}
<simple 
resultType="java.lang.String">${exchangeProperty.templateContents}</simple>{code}
Is the stream cache discarded too soon? If we are not supposed to use it 
anymore after resetting the body I would expect an error of some sort rather 
than an empty result.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to