Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Current stateUnder Discussion

Discussion thread:  https://listswww.mail-archive.com/dev@kafka.apache.org/threadmsg105887.html/r69b11ca1d298a5c849f8af1af0b2708abfc5b1c3e44a402917f6646c%40%3Cdev.kafka.apache.org%3E

JIRA

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-8713

...

Generally, when an optional field which has default value is null, we can treat it as null or default value, it depends on the context.

Public Interfaces

Add a config

...

 property `serialize.accept.optional.

...

null`,

...

 default

...

 `false`, for compatibility.

Proposed Changes

Config property change

Add a config property property `serialize.accept.optional.null null` in org.apache.kafka.connect.storage.ConverterConfigdefault false. This property would only affect JsonConverter in all build-in converters , both  serialization and deserialization. Any third party converters can extend ConverterConfig just like JsonConverterConfig to read this property and implement it.

JsonConverter change

Change private fields TO_CONNECT_CONVERTERS, LOGICAL_CONVERTERS, and private method convertToConnect(Schema schema, JsonNode jsonValue) to no-static.

Serialization(convertToJson),

...

 for an optional null field which has default value,
  • if set serialize.accept.optional.null=true, take null; 
  • if
    set accept.optional.null=false, take default value.

Deserialization(convertToConnectData), for an optional null field which has default value,

  • if set
     set serialize.accept.optional.null=
    true, take null; if set accept.optional.null=
    false, take default value.

Compatibility, Deprecation, and Migration Plan

...

  1. Always take null on an optional null field which has default value. It will break the compatibility and only cover partial cases.
  2. Apply for both serialization and deserialization. I have not see scenario in deserialization.