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

Claus Ibsen reassigned CAMEL-25284:
-----------------------------------

    Assignee: Claus Ibsen

> marshal EIP: add allowNullBody, as unmarshal has
> ------------------------------------------------
>
>                 Key: CAMEL-25284
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25284
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.23.0
>
>
> The *unmarshal* EIP has an {{allowNullBody}} option (advanced, default 
> false): when true, a null body skips the unmarshalling. The *marshal* EIP has 
> no such option.
> Today *marshal* with a null body never fails; the data format marshals the 
> null, and the result depends on the format (checked on 4.23.0-SNAPSHOT):
> * json (Jackson): the 4-character string {{null}}
> * csv: an empty string
> * jacksonXml: {{<null/>}}
> A REST route that marshals a lookup result which came back null therefore 
> answers 200 with the body {{null}}.
> *Proposal:* add {{allowNullBody}} to the marshal EIP (MarshalDefinition, 
> MarshalProcessor, all DSLs, catalog/docs), mirroring unmarshal:
> * {{allowNullBody=true}}: a null body skips the marshalling and the body 
> stays null.
> * default ({{false}}): open for discussion. Keeping today's behaviour is 
> backwards compatible; failing with a clear message (as unmarshal should, see 
> the related ticket) would make marshal and unmarshal symmetric, but changes 
> behaviour, so it would need an upgrade guide note.
> Repro (YAML DSL):
> {code:yaml}
> - route:
>     from:
>       uri: timer:t
>       parameters: {repeatCount: 1}
>       steps:
>         - setBody: {simple: "${null}"}
>         - marshal:
>             json:
>               library: Jackson
>         - convertBodyTo: {type: String}
>         - log: "[${body}]"
> {code}
> logs {{[null]}}.



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

Reply via email to