Camel-Bindy (2.21.2) 固定长度解组似乎忽略了 trim=true 注释

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

我有一个与 Bindy 2.17 一起工作的 class,但是已经迁移到 Camel 2.21.2,当我解组时它不再 trimming 输入数据。

我试过向记录注释添加 paddingChar 属性,但这没有任何效果,因为它是空格,我正在尝试 trim,它应该是默认值paddingChar 无论如何值。

我的 class 的形式是

@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 {

    }

}

配置 trim 的方式是否发生了变化,或者我还遗漏了什么?

谢谢!

我刚遇到同样的问题。默认情况下,固定长度记录右对齐。从版本 2.18 开始,在这种情况下,只有记录左侧的填充字符 trimmed。如果你的填充字符总是在右边,你可以用 align="L" 将你的记录左对齐。如果你只是想 trim 一切独立于对齐,你可以使用 align="B" 从版本 2.20 开始。以下是相关更改:https://github.com/apache/camel/commit/26aa4e8f14cac9dcdaa8f369a8045b8e8df56f1e#diff-24aaa851bf960dc4d2e04c5fbbf8aada