Current state: Accepted
Discussion thread: here
Vote thread: here
Pull request: PR#4033
This means you cannot use them with a java 8 lambda, as that only works for functional interfaces.
Replacing those classes with interfaces makes them lambda compatible.
In the public interface, only
org.apache.kafka.common.KafkaFuture has helper classes which can better be expressed as functional interfaces.
The KIP introduces a
FunctionInterface which defines the new functional interface. The old
Function class is kept for backwards compatibility reasons, but documented to be a candidate for deprecation or removal. The
@Deprecated was not yet added to this class. This was also done for the old signature of the
thenApply function (the only public function which was using this
Biconsumer class was not used in the public interface, it was changed from a class to an interface.
To make it easier to work with the
KafkaFuture the new public function
whenComplete is introduced. This allows the user of
KafkaFuture to execute an action after the future is completed and it matches the signature and the behaviour of
Compatibility, Deprecation, and Migration Plan
In a future release the
thenApply function which uses this class can be marked as
@Deprecated. Later on they can be removed.
When KIP-118 is implemented,
KafkaFuture can extend
CompletableFuture or implement
- Keep the current interface as is, as a nicer syntax to address this api might not be worth breaking backwards compatibility
- Wait for a kafka release which will not support java 7 anymore. And replace or extend
KafkaFuturewith the java 8
CompletionStage. This KIP can then become part of KIP-118: Drop Support for Java 7