1

This is something similar to what I have:

@CsvRecord(separator = "\\t", skipFirstLine = true)
public class Inventory {

    @DataField(pos = 1, required=false)
    private String vendor;

    @DataField(pos = 2, required=false)
    private String sku;

    @DataField(pos = 3, required=false)
    private Integer stock;
}

If any column 2 or 3 are empty, there is no issue at all, those fields just have a null value (imagine that -> is a tab representation).

VENDOR->SKU->STOCK
Vendor1->123->5
Vendor1->->10

With a binding result like

[{
    vendor: "Vendor1",
    sku: "123",
    stock: 5
},
{
    vendor: "Vendor1",
    sku: null,
    stock: 10
}]

So far, so good, but when the first column is null, the column 2 value (sku) is assigned by the binder to the column 1 binded attribute "vendor", and the column 3 value is assinged to the column 2 binded attribute (sku), and the the actual attribute binded to column 3 stays null:

VENDOR->SKU->STOCK
null->123->5
Vendor1->166->10

Does something like this:

[{
    vendor: "123",
    sku: "5",
    stock: null
},
{
    vendor: "Vendor1",
    sku: "166",
    stock: 10
}]

I know I can always make it "required=true" (that's how it was done in the first place), but still it doesn't fail if the second one is not null, since that one is assigned to the first one; and, in the other hand, doing columns required true, in our case is not a good idea, because because one row is missing something, the whole file is rejected, so our strategy is to validate those fields that are mandatory for us manually so we can log it right and process whatever rows are corrects in all columns.

This is my dependency of this library:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-bindy</artifactId>
    <version>2.11.1</version>
</dependency>

And this would be the name of the binding library:

camel-bindy-2.11.1.jar

I checked all attributes I have in the CsvRecord annotation as well as in the DataField annotation, tried blindly with some of them with the hope that will solve it.

Does anyone know why could this be happening? or if it is a library issue solved in later version? or any suggestion I can try?

Of course, I'm grateful in advance for any help or answer I can get!

Tom
  • 16,842
  • 17
  • 45
  • 54
user3049941
  • 87
  • 1
  • 2
  • 9
  • Since there is already 2.17.0 available, please consider an update, to check if this problem might have already been fixed there. – Tom May 17 '16 at 20:18
  • Thanks Tom, I'm now trying different versions of the camel-bindy dependency from the next one of the one we have to the lastest. (Because I already tried the last version first and got an error with another camel dependency, and this app is all camel based, so it's full of camel dependencies, and cannot do a full update of camel versions without a full integration test and we don't have that time now). I'll post any updated of it. Thanks! – user3049941 May 18 '16 at 12:59
  • Well, if you're using camel 2.11.1, then you shouldn't update a single component, because this may has incompatibilities. If possible do a full update of all camel libraries. But we'll see if the single update worked. – Tom May 18 '16 at 13:15

0 Answers0