-
Task
-
Resolution: Done
-
Undefined
-
2024-01-03 - API
-
None
-
False
-
-
False
-
-
At the moment, some modules use Jackson and others use JsonB. To be precise:
- All REST Clients for Quarkus use JsonB
- All REST Clients for Spring Boot use Jackson
- All Quarkus services use JsonB (but swatch-metrics)
- All Spring Boot services use Jackson
- swatch-model-events use Jackson
This might bring incompatibilities (especially for enums) when serializing a model using either JsonB or Jackson and deserializing using the other.
For example, the swatch-model-events use Jackson to generate the model and the enum model looks like this:
@Generated("jsonschema2pojo") public enum CloudProvider { __EMPTY__(""), ALIBABA("Alibaba"), // ... @JsonValue public java.lang.String value() { // ... } @JsonCreator public static Event.CloudProvider fromValue(java.lang.String value) { // ... } }
Where the annotations JsonValue and JsonCreator are Jackson-specific.
Then, if we serialize the enum using Jackson, the JSON will be:
{ "cloud": "Alibaba" }
But if we do the same in JsonB, the json will be:
{ "cloud": "ALIBABA" }
This is because JsonB will ignore the Jackson-specific annotations.
And the situation is very problematic whether the service expects "Alibaba" instead of "ALIBABA". In this case, the service will throw an exception and stop processing the request.
Since we're migrating from Spring Boot which uses Jackson to Quarkus, we should ensure that all the modules we create are Jackson-based and hence use always Jackson.
This issue was spotted in here.
Acceptance Criteria:
- All our modules that generate REST clients and model classes use either jackson or jsonb