Description
Describe the bug
When serializing CallSite
objects to JSON, the CRUDOperations
field is missing if its value is null
. This leads to inconsistencies in the JSON structure, causing downstream processes that rely on the presence of the CRUDOperations
key to fail or behave unexpectedly.
Steps To Reproduce
- Create a
CallSite
object with theCRUDOperations
field set tonull
. - Serialize the
CallSite
object using Gson. - Inspect the resulting JSON output.
- Observe that the
CRUDOperations
key is missing from the JSON.
Observed behavior
The CRUDOperations
key does not appear in the JSON when its value is null
, which disrupts systems expecting a consistent schema with this key present.
Expected behavior
The CRUDOperations
key should appear in the JSON output, even when its value is null
, to maintain a consistent schema for all CallSite
objects.
Error Log
Not applicable, as the issue is related to the absence of expected fields in the JSON structure rather than an explicit error.
Environment (please complete the following information):
- OS: Fedora 41
- Version of Java: 21
- Version of Gson: 2.10.1
- Version of Maven/Gradle: N/A
Additional context
This issue can be resolved by configuring Gson to include null
values during serialization using new GsonBuilder().serializeNulls().create()
.