Details

    • Type: Enhancement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 7.42.0.Final
    • Fix Version/s: None
    • Component/s: KieServer
    • Labels:
      None
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      There are some behaviour differences in JSON payload type handling:

      (A) JSONMarshaller.marshall() produces type with FQCN.

      {
        "org.kie.server.api.marshalling.objects.Pojo1" : {
          "desc" : "C",
          "pojo2" : {
            "org.kie.server.api.marshalling.objects.Pojo2" : {
              "desc2" : "B",
              "primitiveBoolean" : true,
              "pojo3" : {
                "org.kie.server.api.marshalling.objects.Pojo3" : {
                  "desc3" : "A"
                }
              }
            }
          }
        }
      }
      

      This is properly unmarshalled by JSONMarshaller.unmarshall(). And we can consider that this is the standard payload.

      (B) Then, if we edit the above payload to use "simple class name" by removing packages,

      {
        "Pojo1" : {
          "desc" : "C",
          "pojo2" : {
            "Pojo2" : {
              "desc2" : "B",
              "primitiveBoolean" : true,
              "pojo3" : {
                "Pojo3" : {
                  "desc3" : "A"
                }
              }
            }
          }
        }
      }
      

      This is not properly unmarshalled. pojo1's fields are populated but pojo2's fields become 'null'.

      (C) Btw, if we have a type (of "simple class name") only for a top level object,

      {
        "Pojo1" : {
          "desc" : "C",
          "pojo2" : {
              "desc2" : "B",
              "primitiveBoolean" : true,
              "pojo3" : {
                  "desc3" : "A"
                }
              }
            }
          }
        }
      }
      

      This is properly unmarshalled by JSONMarshaller.unmarshall().

      -------------

      So I conclude that "simple class name" works only for a top level object now.

      The "simple class name" is handled by this part of JSONMarshaller$CustomObjectDeserializer.mapObject()

      https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-server-parent/kie-server-api/src/main/java/org/kie/server/api/marshalling/json/JSONMarshaller.java#L749-L754

      because JSONMarshaller$CustomObjectDeserializer.classes contains simple class names:

      https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-server-parent/kie-server-api/src/main/java/org/kie/server/api/marshalling/json/JSONMarshaller.java#L731

      However, the mapObject() is called only for top level objects so nested objects are not properly handled.


      I confirmed with Enrique that (A) is correct and (B) is not. (C) is for convenience.

      So we don't take the behaviour difference as a bug. In other words, users should use (A) approach.

      Enrique noted that he can provide a more uniform way to handle this. So I filed this JIRA.

      FYI) You may use unit tests in this draft PR if useful:
      https://github.com/kiegroup/droolsjbpm-integration/pull/2202

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                elguardian Enrique González Martínez
                Reporter:
                tkobayashi Toshiya Kobayashi
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: