Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
This is a kind of syntactic sugar. Java disallow lambdas to implement abstract classes, and hence there are many ugly impl of Gague in code base [0][1][2][3]. Those bad looking code will spring up as we migrate more and more scala code to java.
Hence, we should offer a variety to accept functional interface for java code. For example:
public final <T> Gauge<T> newGauge(String name, Supplier<T> metric) { return newGauge(name, new Gauge<T>() { @Override public T value() { return metric.get(); } }, Collections.emptyMap()); }
[0] https://github.com/apache/kafka/blob/b015a83f6d286965af999c39c0902584fb6fb9de/server/src/main/java/org/apache/kafka/server/AssignmentsManager.java#L109
[1] https://github.com/apache/kafka/blob/b015a83f6d286965af999c39c0902584fb6fb9de/metadata/src/main/java/org/apache/kafka/image/loader/metrics/MetadataLoaderMetrics.java#L73
[2] https://github.com/apache/kafka/blob/b015a83f6d286965af999c39c0902584fb6fb9de/metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerMetadataMetrics.java#L106
[3] https://github.com/apache/kafka/blob/b015a83f6d286965af999c39c0902584fb6fb9de/storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteStorageThreadPool.java#L54
Attachments
Issue Links
- links to