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

Claus Ibsen resolved CAMEL-24163.
---------------------------------
    Resolution: Fixed

> camel-core - JsonDataFormatReifier passes Jackson-only options to 
> Gson/Fastjson/Jsonb, crashing route startup
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24163
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24163
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-gson
>            Reporter: Federico Mariani
>            Assignee: Claus Ibsen
>            Priority: Major
>              Labels: ai-assisted-review, dataformat
>             Fix For: 4.22.0
>
>         Attachments: GsonJsonDataFormatUseListReifierIssueTest.java
>
>
> *Severity:* High
> *Affects:* 4.x
> h3. Problem
> {{JsonDataFormatReifier.prepareDataFormatConfig}} puts a family of 
> Jackson-only options into the property map *unconditionally for every 
> library* (only 
> {{schemaResolver}}/{{namingStrategy}}/{{timezone}}/{{maxStringLength}} are 
> guarded by {{library == Jackson}}):
> {code:java}
> properties.put("include", definition.getInclude());
> properties.put("allowJmsType", definition.getAllowJmsType());
> properties.put("collectionType", ...);
> properties.put("useList", definition.getUseList());
> properties.put("enableFeatures", ...);
> properties.put("disableFeatures", ...);
> properties.put("allowUnmarshallType", ...);
> // ... moduleClassNames, moduleRefs, combineUnicodeSurrogates
> {code}
> {{GsonDataFormat}}, {{FastjsonDataFormat}} and {{JsonbDataFormat}} have no 
> such setters, and binding is mandatory, so setting any of these documented 
> options crashes route startup.
> h3. Failure scenario
> {code:xml}
> <unmarshal><json library="Gson" useList="true"/></unmarshal>
> {code}
> {noformat}
> PropertyBindingException: Error binding property (useList=true) with name: 
> useList
>   on bean: org.apache.camel.component.gson.GsonDataFormat
>   at DataFormatReifier.configureDataFormat(DataFormatReifier.java:316)
> {noformat}
> Reproduced with 
> {{useList/collectionType/include/enableFeatures/disableFeatures/allowJmsType/allowUnmarshallType}}
>  on Gson, Fastjson and Jsonb.
> h3. Suggested fix
> Guard the non-Jackson-supported option family per library (mirror the 
> existing {{library == Jackson}} block), or emit a clear "option X is not 
> supported by library Y" message instead of a raw binding failure.
> h3. Reproducer
> Attached {{GsonJsonDataFormatUseListReifierIssueTest.java}} builds a route 
> with a {{JsonDataFormat}} model ({{library=Gson}}, {{useList=true}}) and 
> asserts the context starts and unmarshals a JSON array to a {{List}}; RED on 
> current code.
> ----
> _Reported by Claude Code on behalf of Federico Mariani (Croway). A failing 
> JUnit reproducer (confirmed RED on 4.22.0-SNAPSHOT) is attached._



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

Reply via email to