Skip to content

Change TypeSerializerBase to skip generator.writeTypePrefix() for null typeId #3373

@cowtowncoder

Description

@cowtowncoder

(note: offshoot of FasterXML/jackson-core#584)

It seems that there are cases where Type Id resolution would be best handled by avoiding call altogether: specifically, when there is no Type Id passed (that is, null is passed).
This is handled in method TypeSerializerBase.writeTypePrefix(); and requires some matching changes in TypeSerializerBase.writeTypeSuffix() as well.

The idea here is to:

  1. Return null from writeTypePrefix() if no typeId passed.
  2. In writeTypeSuffix(), skip processing if WritableTypeId passed is null (but not necessarily if WritableTypeId.id is null)

and hopefully this will allow essentially avoiding the write, in a safe and clean manner.
The one possible complication case is that of if some existing code relied on null typeId being passed (null for WritableId would never work, would NPE). There isn't any good reliable way to catch that but... let's hope 2.14 RCs give a chance for downstream deps to check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions