Skip to content

[Backport] Globally disable AUTO_CLOSE_JSON_CONTENT.#16149

Merged
LakshSingla merged 1 commit intoapache:29.0.1from
cryptoe:backport-15880-to-29.0.1
Mar 19, 2024
Merged

[Backport] Globally disable AUTO_CLOSE_JSON_CONTENT.#16149
LakshSingla merged 1 commit intoapache:29.0.1from
cryptoe:backport-15880-to-29.0.1

Conversation

@cryptoe
Copy link
Copy Markdown
Contributor

@cryptoe cryptoe commented Mar 18, 2024

Backport of #15880 to 29.0.1.

* Globally disable AUTO_CLOSE_JSON_CONTENT.

This JsonGenerator feature is on by default. It causes problems with code
like this:

  try (JsonGenerator jg = ...) {
    jg.writeStartArray();
    for (x : xs) {
      jg.writeObject(x);
    }
    jg.writeEndArray();
  }

If a jg.writeObject call fails due to some problem with the data it's
reading, the JsonGenerator will write the end array marker automatically
when closed as part of the try-with-resources. If the generator is writing
to a stream where the reader does not have some other mechanism to realize
that an exception was thrown, this leads the reader to believe that the
array is complete when it actually isn't.

Prior to this patch, we disabled AUTO_CLOSE_JSON_CONTENT for JSON-wrapped
SQL result formats in apache#11685, which fixed an issue where such results
could be erroneously interpreted as complete. This patch fixes a similar
issue with task reports, and all similar issues that may exist elsewhere,
by disabling the feature globally.

* Update test.
@LakshSingla LakshSingla merged commit 4944327 into apache:29.0.1 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants