[
https://issues.apache.org/jira/browse/CAMEL-20802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Raymond updated CAMEL-20802:
----------------------------
Attachment: main-xml.zip
> Velocity shows error when using ${headers}
> ------------------------------------------
>
> Key: CAMEL-20802
> URL: https://issues.apache.org/jira/browse/CAMEL-20802
> Project: Camel
> Issue Type: Bug
> Components: camel-velocity
> Affects Versions: 4.6.0
> Reporter: Raymond
> Priority: Minor
> Attachments: main-xml.zip
>
>
> In Camel 3 (3.20.8) I have the following route:
> {code:java}
> <route id="myRoute">
> <from uri="direct:in"/>
> <setHeader headerName="CamelVelocityTemplate">
> <simple>${headers}</simple>
> </setHeader>
> <to uri="velocity:generate"/>
> <to
> uri="log:foo//?skipBodyLineSeparator=false&multiline=true&showHeaders=false&showBody=true&showBodyType=true&showFiles=true&showException=false&showStackTrace=false&showCaughtException=false"/>
> </route> {code}
> Then I get an output like this:
> {code:java}
> {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}
> {code}
> However when running the route with Camel 4 (using 4.6.0 on JDK21) I get the
> following error:
> {code:java}
> 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)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)