This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new a65626b6a80 MINOR: Add functionalinterface to the producer callback
(#19366)
a65626b6a80 is described below
commit a65626b6a806fca960377f9fd5d5383cdcb72946
Author: Thomas Gebert <[email protected]>
AuthorDate: Sun Apr 6 10:21:09 2025 -0400
MINOR: Add functionalinterface to the producer callback (#19366)
The Callback interface is a perfect example of a place that can use the
functionalinterface in Java. Strictly for Java, this isn't "required"
since Java will automatically coerce, but for Clojure (and other JVM
languages I belive) to interop with Java lambdas it needs the
FunctionalInterface annotation.
Since FunctionalInterface doesn't add any overhead and provides
compiler-enforced documentation, I don't see any reason *not* to have
this. This has already been added into Kafka Streams here:
https://github.com/apache/kafka/pull/19234#pullrequestreview-2740742487
I am happy to add it to any other spots in that might be useful too.
Reviewers: Chia-Ping Tsai <[email protected]>
---
clients/src/main/java/org/apache/kafka/clients/producer/Callback.java | 1 +
.../runtime/src/main/java/org/apache/kafka/connect/util/Callback.java | 1 +
2 files changed, 2 insertions(+)
diff --git
a/clients/src/main/java/org/apache/kafka/clients/producer/Callback.java
b/clients/src/main/java/org/apache/kafka/clients/producer/Callback.java
index 2eb7ebc882b..5c8f159ac82 100644
--- a/clients/src/main/java/org/apache/kafka/clients/producer/Callback.java
+++ b/clients/src/main/java/org/apache/kafka/clients/producer/Callback.java
@@ -20,6 +20,7 @@ package org.apache.kafka.clients.producer;
* A callback interface that the user can implement to allow code to execute
when the request is complete. This callback
* will generally execute in the background I/O thread so it should be fast.
*/
+@FunctionalInterface
public interface Callback {
/**
diff --git
a/connect/runtime/src/main/java/org/apache/kafka/connect/util/Callback.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/util/Callback.java
index fd62fc172f4..f628e822274 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/util/Callback.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/util/Callback.java
@@ -19,6 +19,7 @@ package org.apache.kafka.connect.util;
/**
* Generic interface for callbacks
*/
+@FunctionalInterface
public interface Callback<V> {
/**
* Invoked upon completion of the operation.