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

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

Fixed by https://github.com/apache/camel/pull/30228 (merged as 24ae572d9034) on 
main for 4.24.0.

_Claude Code on behalf of davsclaus_

> camel-bindy - fixed-length trim removes the value 0 of a number padded with 
> '0', so it unmarshals to null or MIN_VALUE
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27058
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27058
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-bindy
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> With {{trim = true}} and {{paddingChar = '0'}} on a numeric {{@DataField}} of 
> a fixed-length record, unmarshal trims every '0' of a field that holds the 
> value 0 ({{000}}), so the field is read as empty: an {{Integer}} gets 
> {{null}}, an {{int}} gets {{Integer.MIN_VALUE}}, a {{required}} field fails 
> with "The mandatory field defined at the position 1 is empty", and a 
> {{defaultValue}} replaces the 0. Marshal writes 0 as {{000}}, so 0 does not 
> survive a marshal and unmarshal round trip. Without {{trim}}, the same field 
> is read as 0.
> {code:java}
> @FixedLengthRecord(length = 6)
> public class Counts {
>     @DataField(pos = 1, length = 3, paddingChar = '0', trim = true)
>     Integer boxed; // "000" -> null
>     @DataField(pos = 4, length = 3, paddingChar = '0', trim = true)
>     int prim;      // "000" -> -2147483648
> }
> from("direct:start").unmarshal(new BindyFixedLengthDataFormat(Counts.class)); 
> // body "000000"
> {code}
> Expected: when trimming the padding char '0' leaves nothing of a numeric 
> field, the field is 0 (with the precision of the field for a {{BigDecimal}}). 
> Text fields, and numeric fields that are empty or padded with another char, 
> keep their current behaviour.
> _Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to