Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-13937

REST API cannot handle java.time.* values anymore

XMLWordPrintable

    • Icon: Bug Report Bug Report
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.17.0, 7.15.8, 7.16.2, 7.17.0-alpha2
    • 7.16.0, 7.12.21, 7.13.17, 7.14.11, 7.15.5
    • None

      Environment (Required on creation):

      • Camunda Platform 7.15.5
      • Spring Boot Starter 2.5.X

      Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):

      REST API cannot serialize java.time.* values.

      Steps to reproduce (Required on creation):

      • Create a custom Pojo with a field of type java.time.LocalDate
      • Store an object of this Pojo as a process variable
      • In Cockpit, view the variable value (inspect variable dialog)

      Observed Behavior (Required on creation):

      The variable endpoint GET /variable-instance/[ID] returns status code 400 with the following response:

      com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDate` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: PojoWithLocalDate["localDate"])
      

      Expected behavior (Required on creation):

      The object typed variable is deserialized and serialized again in the REST API and can be displayed in Cockpit.

      Root Cause (Required on prioritization):

      • Starting with Jackson Databind 2.12 java.time.* values cannot be serialized anymore when the com.fasterxml.jackson.datatype:jackson-datatype-jsr310 is not registered in the ObjectMapper [1].
      • For the Spring Boot Starter with CAM-9972 we implemented that it automatically configures and registers the module for the ObjectMapper used in the engine when the module is available on the classpath
        • We don't have such logic for the ObjectMapper configured in the REST API [2]
      • While with Jackson Databind < 2.12 users did not have this problem since the library applied its default strategies to serialize a java.time.* object as it does for any other Pojo

      Solution Ideas (Optional):

      1. In JacksonConfigurator#configureObjectMapper, call ObjectMapper#findAndRegisterModules
        • This registers all Jackson modules that are available on the classpath automatically (via a service loader descriptor present in the respective module)
      2. Make it possible to configure JacksonConfigurator for jackson modules similar to how we do it already for the date format (via a static field)
      3. Make JacksonConfigurator configurable for users and call ObjectMapper#findAndRegisterModules only in the Spring Boot Starter
      4. Use the Spring Boot Starter's ObjectMapper bean in the REST API and configure it accordingly
      5. Use the engine's ObjectMapper in the REST API

      Hints (optional):

      • Using ObjectMapper#findAndRegisterModules could simplify the implementation of CAM-9972 tremendously and make it more robust.
      • When this is fixed, update the migration guide that the serialization format of java.time.* values have changed.
      • This is probably also a problem in context of other application servers and not only for Spring Boot

      [1] https://github.com/FasterXML/jackson-databind/issues/2683
      [2] https://github.com/camunda/camunda-bpm-platform/blob/master/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/mapper/JacksonConfigurator.java

        This is the controller panel for Smart Panels app

          1. java8time.bpmn
            3 kB
            Tobias Metzke-Bernstein

              christina.ausley Christina Ausley
              tassilo.weidner Tassilo Weidner
              Tobias Metzke-Bernstein Tobias Metzke-Bernstein
              Nikola Koevski Nikola Koevski
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: