Andrea Cosentino created CAMEL-24426:
----------------------------------------

             Summary: camel-gson, camel-jsonb, camel-jaxb - gate the 
unmarshal-type header behind an opt-in like camel-jackson does
                 Key: CAMEL-24426
                 URL: https://issues.apache.org/jira/browse/CAMEL-24426
             Project: Camel
          Issue Type: Improvement
          Components: camel-gson
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.23.0


camel-jackson gates the type-selecting header behind an explicit option:

{code:java}
Class<?> clazz = unmarshalType;
String type = null;
if (allowUnmarshallType) {
    type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, 
String.class);
}
{code}

The sibling data formats honour their equivalent header unconditionally:

* camel-gson GsonDataFormat.unmarshal() - GsonConstants.UNMARSHAL_TYPE
* camel-jsonb JsonbDataFormat.unmarshal() - "CamelJsonbUnmarshallType"
* camel-jaxb JaxbDataFormat - partClassFromHeader, resolved via 
ClassResolver.resolveMandatoryClass

grep for allowUnmarshallType across camel-gson, camel-jsonb, camel-jaxb and 
camel-fastjson returns nothing, so none of them has the gate.

Proposal: add an allowUnmarshallType option (default false) to each of these 
data formats, mirroring camel-jackson's naming and semantics, so the header is 
only consulted when the route author opts in. This is a behaviour change for 
routes that rely on the header today, so it needs an upgrade-guide entry. 
Consider filing camel-fastjson separately if it has an equivalent header.



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

Reply via email to