Skip to content

Fix triple-quoted clobs ending across pages - #1188

Merged
junyans merged 2 commits into
masterfrom
triple-quoted-clob-small-reads
Dec 2, 2026
Merged

junyans merged 2 commits into
masterfrom
triple-quoted-clob-small-reads

Conversation

@junyans

@junyans junyans commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Issue #, if available: #1187

Description of changes:

Problem

The text reader throws IllegalArgumentException on a valid triple-quoted clob or field name when its closing ''' fall on different pages: for example {{'''abc'''}} read from a stream that returns 1, 2, 3, 5 or 6 bytes per read(), or a clob whose closing quotes straddle the end of a 32K page.

Cause

After the closing quotes, skip_triple_quoted_string marks the end of the text at the first of them with sp.markEnd(-3), which can be on an earlier page. save_point_mark_end moved to the previous page with getBufferLimit() - pos_offset, but pos_offset is negative, so every step back threw. It also stepped back at most one page.

Change

  • save_point_mark_end steps back a page at a time with getBufferLimit() + pos_offset, but not before the page where the save point starts.
  • New tests in IonReaderTextFastPathsTest read triple-quoted clobs and field names at every bytes-per-read value, and with the closing quotes across the end of a full page. malformedValuesLeaveTheReaderUsable now also runs its triple-quoted clob with 1-byte reads.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When the closing quotes of a clob or field name fall on different pages,
marking where its text ends stepped back with the wrong sign and at most
one page, so valid input threw. Any page end can split them, and streams
returning a few bytes per read split them often.

Fixes #1187
* See: https://github.com/amazon-ion/ion-java/issues/1187
*/
@Test
public void tripleQuotedTextReadsTheSameWhereverPagesEnd() throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split this into several parameterized tests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated it now

So each input and read size runs as its own case, and a failure names
the input and read size instead of stopping the whole test.

Addresses review comment on #1188
@junyans
junyans merged commit 5d17cf0 into master Dec 2, 2026
16 checks passed
@tgregg
tgregg deleted the triple-quoted-clob-small-reads branch December 2, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants