Conversation
Signed-off-by: Jake Wang <jakezwang@users.noreply.github.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Signed-off-by: Jake Wang <jakezwang@users.noreply.github.com>
eamonnmcmanus
left a comment
There was a problem hiding this comment.
Thanks! While this is technically a behaviour change, it is replacing one exception with another, so the risk of breakage seems minor. Meanwhile it does seem like a more consistent result.
I ran this past all of Google's internal tests and there were no failures.
|
(We do need the CLA to be signed before we can accept this change, though.) |
|
Would a test for Maybe trying to deserialize something like |
|
Added the EOF regression in ad0db44. Deserializing |
Purpose
Closes #1907. Preserve the original checked
IOExceptionwhenTypeAdapter.read/TypeAdapter.fromJson(Reader)encounters a stream failure while reading a registeredJsonDeserializer's JSON tree.Description
Streams.parsewraps a reader's I/O failures inJsonIOException. Unwrap that specific exception at the streamingTreeTypeAdapterboundary, wherereadalready declaresIOException. This lets callers handle errors such as a socket timeout consistently with other streaming adapters.The catch only surrounds tree parsing: exceptions deliberately thrown by a custom deserializer retain their existing type and identity. Empty-document and malformed-JSON handling in
Streams.parseremains in place. This does not change the broaderGson.fromJsonI/O-exception policy discussed in #1112 / #1023.Added regression coverage for a
SocketTimeoutExceptionbefore any input and in the middle of an object, plus a custom-deserializer exception preservation check and an incomplete-array regression that keepsEOFExceptionwrapped inJsonSyntaxException. The checked-I/O test fails before the fix.Validation on JDK 17:
mvn clean verify javadoc:jarpassed for every reactor module, including formatting, JPMS, ProGuard/R8, extras, metrics, and protobuf. The Gson module ran 4,676 tests with 20 skipped and no failures/errors. After moving reader construction outsideassertThrowsto satisfy the JDK 21+ Error Prone check, the focusedTreeTypeAdaptersTestsuite also passed.Checklist
spotlesspassed).mvn clean verify javadoc:jarpasses without errors.Implementation and validation were performed primarily with OpenAI Codex.