You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.

Status

Current stateUnder Discussion

Discussion thread: TBD

JIRA: Unable to render Jira issues macro, execution error.

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

In most cases the method close() and configure() are useless for kafka users. Since kafka 2.x+ is up on jdk8, we can add the default implementation in order to enable kafka user to write less code to implement custom Serializer, Deserializer, and Serde.

Proposed Changes && Public Interfaces

In org.apache.kafka.common.serialization.Serde, org.apache.kafka.common.serialization.Serializer and org.apache.kafka.common.serialization.Deserializer, we will add empty implementations to close() and configure(). Also, we will add the annotation "FunctionalInterface" to Deserializer and Serializer.

Serde.java
default void configure(Map<String, ?> configs, boolean isKey) {
  // intentionally left blank
}
default void close() {
  // intentionally left blank
}
Serializer
@FunctionalInterface
public interface Serializer<T> extends Closeable {
 default void configure(Map<String, ?> configs, boolean isKey) {
    // intentionally left blank
  }
  default void close() {
    // intentionally left blank
  }
}
Deserializer
@FunctionalInterface
public interface Deserializer<T> extends Closeable {
  default void configure(Map<String, ?> configs, boolean isKey) {
    // intentionally left blank
  }
  default void close() {
    // intentionally left blank
  }
}

Compatibility, Deprecation, and Migration Plan

  • The change of this KIP is backward compatible since the default implementation won't break the BC and SC
  • No compiler error happens even if close() or configure() isn't implemented. 

Rejected Alternatives

None

  • No labels