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 <chia7712@gmail.com>
This commit is contained in:
Thomas Gebert 2025-04-06 10:21:09 -04:00 committed by GitHub
parent 9f676dd7e2
commit a65626b6a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -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 {
/**

View File

@ -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.