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

Velocity shows error when using ${headers}

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Cannot Reproduce
    • 4.6.0
    • None
    • camel-velocity
    • None
    • Unknown

    Description

      In Camel 3 (3.20.8) I have the following route:

      <route id="myRoute">
              <from uri="direct:in"/>
              <setHeader headerName="CamelVelocityTemplate">
                  <simple>${headers}</simple>
              </setHeader>
              <to uri="velocity:generate"/>
              <to uri="log:foo//?skipBodyLineSeparator=false&amp;multiline=true&amp;showHeaders=false&amp;showBody=true&amp;showBodyType=true&amp;showFiles=true&amp;showException=false&amp;showStackTrace=false&amp;showCaughtException=false"/>
          </route>     

      Then I get an output like this:

      {Accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7, Accept-Encoding=gzip, deflate, br, zstd, Accept-Language=nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7, breadcrumbId=7FE304808A5EF7B-0000000000008538, CamelServletContextPath=/regressiontests/Velocity, CamelVelocityTemplate=(this Map), ComponentInitTime=1716561470224, Connection=close, Cookie=_ga=GA1.1.1085399545.1665049218; _ga_J0TKN8HXSY=GS1.1.1715979059.148.0.1715979059.0.0.0; nPT0%3D--35c503a9ecbf1d3922b78a7289ee8eb8f80e1d36, Host=assimbly-test:9001, sec-ch-ua="Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24", sec-ch-ua-mobile=?0, sec-ch-ua-platform="Windows", Sec-Fetch-Dest=document, Sec-Fetch-Mode=navigate, Sec-Fetch-Site=none, Sec-Fetch-User=?1, Upgrade-Insecure-Requests=1, User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36} 

      However when running the route with Camel 4 (using 4.6.0 on JDK21) I get the following error:

      java.lang.StackOverflowError: null
              at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:806)
              at java.base/java.lang.StringBuffer.append(StringBuffer.java:425)
              at java.base/java.io.StringWriter.write(StringWriter.java:79)
              at org.apache.camel.util.json.Jsoner.serialize(Jsoner.java:963)
              at org.apache.camel.util.json.Jsoner.serialize(Jsoner.java:1004)
              at org.apache.camel.util.json.Jsoner.serialize(Jsoner.java:1006) 

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            skin27 Raymond
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment