@Override
    public OUT nextRecord(OUT record) throws IOException {
        OUT returnRecord = null;
        do {
            returnRecord = super.nextRecord(record);
        } while (returnRecord == null && !reachedEnd());

        return returnRecord;
    }
@Test
    void testReadSparseWithNullFieldsForTypes() {
        try {
            final String fileContent =
                    "111|x|222|x|333|x|444|x|555|x|666|x|777|x|888|x|999|x|000|x|\n"
                            + "000|x|999|x|888|x|777|x|666|x|555|x|444|x|333|x|222|x|111|x|";
            final FileInputSplit split = createTempFile(fileContent);

            final TupleTypeInfo<Tuple3<Integer, Integer, Integer>> typeInfo =
                    TupleTypeInfo.getBasicTupleTypeInfo(
                            Integer.class, Integer.class, Integer.class);
            final CsvInputFormat<Tuple3<Integer, Integer, Integer>> format =
                    new TupleCsvInputFormat<Tuple3<Integer, Integer, Integer>>(
                            PATH,
                            typeInfo,
                            new boolean[] {true, false, false, true, false, false, false, true});

            format.setFieldDelimiter("|x|");

            format.configure(new Configuration());
            format.open(split);

            Tuple3<Integer, Integer, Integer> result = new Tuple3<>();

            result = format.nextRecord(result);
            assertThat(result.f0).isEqualTo(Integer.valueOf(111));
            assertThat(result.f1).isEqualTo(Integer.valueOf(444));
            assertThat(result.f2).isEqualTo(Integer.valueOf(888));

            result = format.nextRecord(result);
            assertThat(result.f0).isEqualTo(Integer.valueOf(000));
            assertThat(result.f1).isEqualTo(Integer.valueOf(777));
            assertThat(result.f2).isEqualTo(Integer.valueOf(333));

            result = format.nextRecord(result);
            assertThat(result).isNull();
            assertThat(format.reachedEnd()).isTrue();
        } catch (Exception ex) {
            fail("Test failed due to a " + ex.getClass().getName() + ": " + ex.getMessage());
        }
    }