You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/10/11 19:50:00 UTC

[jira] [Resolved] (CAMEL-17067) Datasonnet header can't be used to set bodyMediaType

     [ https://issues.apache.org/jira/browse/CAMEL-17067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-17067.
---------------------------------
    Fix Version/s: 3.11.4
                   3.13.0
       Resolution: Fixed

> Datasonnet header can't be used to set bodyMediaType
> ----------------------------------------------------
>
>                 Key: CAMEL-17067
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17067
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 3.11.1, 3.11.2, 3.11.0
>            Reporter: Henrik Karlsson
>            Priority: Minor
>             Fix For: 3.13.0, 3.11.4
>
>
> Using the Datasonnet Header to specify the media type for the body doesn't work because then doEvalute() inte DatasonnetExpression fails to detect the media type the body is set like this:
> {code:java}
> body = new DefaultDocument<>(MessageHelper.extractBodyAsString(exchange.getMessage()), bodyMT);{code}
> This only works if the current body is a String.
> If I remove the bodyMediaType attribute from the datasonnet processor in the route in the test case testReadJava(), which has a java object as body and a header that looks like this:
> {code:java}
> /** DataSonnet
> version=2.0
> input payload application/x-java-object; DateFormat=yyyy-MM-dd
> */
> {code}
> Then this test case fails with:
> java.lang.IllegalArgumentException: Problem executing script: sjsonnet.Error: attempted to index a string with string name    at line 24 column 24 of the transformation
>  at com.datasonnet.Mapper.transform(Mapper.scala:267) at org.apache.camel.language.datasonnet.DatasonnetExpression.doEvaluate(DatasonnetExpression.java:142) at org.apache.camel.language.datasonnet.DatasonnetExpression.evaluate(DatasonnetExpression.java:87) ... 86 more



--
This message was sent by Atlassian Jira
(v8.3.4#803005)