apache-camelbindy

Camel-Bindy (2.21.2) Fixed length unmarshalling appears to be ignoring trim=true annotation


I've a class that was working with Bindy 2.17, but having migrated to Camel 2.21.2, it is no longer trimming the incoming data when I unmarshall.

I've tried adding a paddingChar attribute to the record annotation, but that has had no effect, and as it is spaces I'm trying to trim, it should be the default paddingChar value anyway.

My class is of the form

@FixedLengthRecord( header = MyClass.MyHeader.class, footer = MyClass.MyFooter.class, skipHeader = true, skipFooter = true, ignoreTrailingChars = true, crlf="WINDOWS", paddingChar = ' ' )
public class MyClass{

    @DataField( pos = 1, length = 2, trim = true )
    private String field1;

    @DataField( pos = 2, length = 15, trim = true )
    private String field2;

    @DataField( pos = 3, length = 15, trim = true )
    private String field3;

    @FixedLengthRecord( ignoreTrailingChars = true )
    public static class MyHeader {

    }

    @FixedLengthRecord( ignoreTrailingChars = true)
    public static class MyFooter {

    }

}

Has something changed in the way trim is configured, or is there something else I'm missing?

Thanks!


Solution

  • I just had the same issue. By default, fixed length records are aligned to the right. Starting in version 2.18, only padding characters to the left of the record are trimmed in this case. If your padding characters are always on the right, you can align your record left with align="L". If you just want to trim everything independent of the alignment, you can use align="B" starting in version 2.20. Here is the relevant change: https://github.com/apache/camel/commit/26aa4e8f14cac9dcdaa8f369a8045b8e8df56f1e#diff-24aaa851bf960dc4d2e04c5fbbf8aada