Skip to content

Text reader throws IllegalArgumentException on a valid triple-quoted clob read from a stream in small chunks #1187

Backlog

Description

@junyans

Reading a valid clob written with a triple-quoted string from an InputStream that returns only a few bytes per read() fails:

InputStream in = new FilterInputStream(new ByteArrayInputStream("{{'''abc'''}}".getBytes(StandardCharsets.UTF_8))) {
    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        return super.read(b, off, Math.min(len, 1));
    }
};
try (IonReader reader = IonReaderBuilder.standard().build(in)) {
    reader.next();
    reader.newBytes(); // IllegalArgumentException: end point [5] must be within 1 page of current [6]
}

With this 13-byte input it fails for 1, 2, 3, 5 and 6 bytes per read and succeeds for 4, 7 and 8. Seen on v1.12.1 and v1.12.2.

java.lang.IllegalArgumentException: end point [5] must be within 1 page of current [6]
  at com.amazon.ion.impl.UnifiedSavePointManagerX.end_point_too_far(UnifiedSavePointManagerX.java:272)
  at com.amazon.ion.impl.UnifiedSavePointManagerX.save_point_mark_end(UnifiedSavePointManagerX.java:258)
  at com.amazon.ion.impl.UnifiedSavePointManagerX$SavePoint.markEnd(UnifiedSavePointManagerX.java:334)

After the closing quotes, the skip calls sp.markEnd(-3) (IonReaderTextRawTokensX.java:2279). save_point_mark_end moves back at most one page (UnifiedSavePointManagerX.java:245-259), and since each refill takes a new page while a value is being saved, three characters back can be more than one page back.

Found while adding tests in #1185, which leave this combination out.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions