Skip to content

Catch Throwable in GxUserType.getJsonObject to avoid breaking SDT serialization#1104

Merged
iroqueta merged 1 commit intomasterfrom
fix/gxusertype-catch-throwable
Apr 29, 2026
Merged

Catch Throwable in GxUserType.getJsonObject to avoid breaking SDT serialization#1104
iroqueta merged 1 commit intomasterfrom
fix/gxusertype-catch-throwable

Conversation

@iroqueta
Copy link
Copy Markdown
Collaborator

Summary

  • Widens the catch in getJsonObject from Exception to Throwable so that Error subclasses (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 HashMap Jackson serializes it fully, invoking reflectively every getter. HttpContextNull.getPostData() and HttpContextNull.getResponse() throw InternalError, which extends Error and therefore escaped catch(Exception). The error propagated up through GXSimpleCollection.toJSonString() and broke any SDT that holds an HttpContext reference (reported on GAMLoginAdditionalParameters).

Test plan

  • Reproduce with the xpz provided in the issue (proc that calls GAMLoginAdditionalParameters.Properties.ToJson()) before the fix and confirm the InternalError stacktrace
  • Apply the patched JAR and run the same proc — should complete without the error and log the serialization failure
  • Regression: run existing unit tests under java/

Issue: 208409

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.
@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

@iroqueta iroqueta merged commit 62c0298 into master Apr 29, 2026
10 checks passed
@iroqueta iroqueta deleted the fix/gxusertype-catch-throwable branch April 29, 2026 21:15
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.

2 participants