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

        return returnRecord;
    }
@Test
    void readStringFieldsWithTrailingDelimiters() {
        try {
            final String fileContent = "abc|-def|-ghijk\nabc|-|-hhg\n|-|-|-\n";
            final FileInputSplit split = createTempFile(fileContent);

            final TupleTypeInfo<Tuple3<String, String, String>> typeInfo =
                    TupleTypeInfo.getBasicTupleTypeInfo(String.class, String.class, String.class);
            final CsvInputFormat<Tuple3<String, String, String>> format =
                    new TupleCsvInputFormat<>(PATH, typeInfo);

            format.setFieldDelimiter("|-");

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

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

            result = format.nextRecord(result);
            assertThat(result.f0).isEqualTo("abc");
            assertThat(result.f1).isEqualTo("def");
            assertThat(result.f2).isEqualTo("ghijk");

            result = format.nextRecord(result);
            assertThat(result.f0).isEqualTo("abc");
            assertThat(result.f1).isEmpty();
            assertThat(result.f2).isEqualTo("hhg");

            result = format.nextRecord(result);
            assertThat(result.f0).isEmpty();
            assertThat(result.f1).isEmpty();
            assertThat(result.f2).isEmpty();

            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());
        }
    }