Catch Throwable in GxUserType.getJsonObject to avoid breaking SDT serialization#1104
Merged
Catch Throwable in GxUserType.getJsonObject to avoid breaking SDT serialization#1104
Conversation
Since Jackson now serializes full objects when they are not HashMap (commit 3e2b9e7), reflective invocation of getters like HttpContextNull.getPostData() / getResponse() can throw InternalError. InternalError extends Error (not Exception), so catch(Exception) did not catch it and the error propagated up through GXSimpleCollection .toJSonString(), breaking any call that serialized an SDT containing an HttpContext (e.g. GAMLoginAdditionalParameters). Widening the catch to Throwable lets getJsonObject log the problem and return an empty JSON object, preserving the previous behavior for objects that fail reflective serialization.
Collaborator
Cherry pick to beta success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getJsonObjectfromExceptiontoThrowableso thatErrorsubclasses (e.g.InternalError) are logged and swallowed the same way other failures are, returning an empty JSON object instead of breaking the caller.Background
Since 3e2b9e7, when the object is not a
HashMapJackson serializes it fully, invoking reflectively every getter.HttpContextNull.getPostData()andHttpContextNull.getResponse()throwInternalError, which extendsErrorand therefore escapedcatch(Exception). The error propagated up throughGXSimpleCollection.toJSonString()and broke any SDT that holds anHttpContextreference (reported onGAMLoginAdditionalParameters).Test plan
GAMLoginAdditionalParameters.Properties.ToJson()) before the fix and confirm theInternalErrorstacktracejava/Issue: 208409