jackson-dataformats-binary icon indicating copy to clipboard operation
jackson-dataformats-binary copied to clipboard

ION - MappingIterator skip the first line

Open loicmathieu opened this issue 2 months ago • 0 comments

When reading an ION file using a MappingIterator, the first line is omitted.

        // This file has 5 lines
        File testFile = resourceToFile("test.ion");

        ObjectMapper objectMapper = JacksonUtils.createIonObjectMapper();
        MappingIterator<Object> mappingIterator = objectMapper.readerFor(DEFAULT_TYPE_REFERENCE).readValues(new FileInputStream(testFile));

        // the first line is missing
        LongAdder count = new LongAdder();
        mappingIterator.forEachRemaining(obj -> {
            count.increment();
        });
        Assertions.assertEquals(5, count.sum()); // fails as count.sum() returns 4 and not 5 as the first line is missing

When reading in a more traditional approach the object mapper correctly read all 5 lines

Reproducer project, there is a test in it:
mapping-iterator.zip

loicmathieu avatar May 07 '24 16:05 loicmathieu