Skip to content

Conversation

@dpolysiou
Copy link
Contributor

When returning JSON scalar data from a field, we can return the JsonValue object as is, without recursively traversing the pojo.

This makes a difference when the field payload is large, as it avoids performing unnecessary work on the event loop thread. Here is an example where an unreasonably large field leads to blocking the event loop thread.

@jmartisk
Copy link
Member

jmartisk commented Sep 19, 2025

If you look a few lines below, we have some more customized logic for processing the object, like acting on the isExcludeNullFieldsInResponses configuration field, will this not break that functionality? I guess you would skip the removal of nulls from the response if isExcludeNullFieldsInResponses==true with this code.

Perhaps a good solution would be to leave it to the original custom logic if isExcludeNullFieldsInResponses==true (or even better, implement a faster version of it specifically for JsonValue that would only remove nulls, but that's optional for now) and do your thing of returning the JsonValue directly only if isExcludeNullFieldsInResponses==false?

@dpolysiou
Copy link
Contributor Author

I added a method similar to the handling of Map that produces a copy of the JsonValue, with null fields excluded. I hope that's fine.

@jmartisk
Copy link
Member

Thanks!

@jmartisk jmartisk merged commit befccf6 into smallrye:main Sep 22, 2025
5 checks passed
@github-actions github-actions bot added this to the 2.12.3 milestone Sep 22, 2025
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