Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-1945

[Spike] Use jackson in our REST clients/model generators for Quarkus and Spring Boot

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • 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

            awood1@redhat.com Alex Wood
            jcarvaja@redhat.com Jose Carvajal Hilario
            Sumedh Sidhaye Sumedh Sidhaye
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: