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

setBody clears/invalidates streamcache still being used in header/property

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Information Provided
    • 4.0.3
    • None
    • came-core
    • None
    • Unknown

    Description

      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.

      <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}" /> 

      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:

      <simple resultType="java.lang.String">${exchangeProperty.templateContents}</simple>

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rikvb Rik van Ballegooijen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: