You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Chia-Ping Tsai (Jira)" <ji...@apache.org> on 2026/08/18 11:16:00 UTC
[jira] [Commented] (KAFKA-20958) Introduce internal accessor pattern to encapsulate cross-package APIs
[ https://issues.apache.org/jira/browse/KAFKA-20958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18105573#comment-18105573 ]
Chia-Ping Tsai commented on KAFKA-20958:
----------------------------------------
{code:java}
@InterfaceAudience.Public
public final class Metrics implements Closeable {
// ...
/**
* @deprecated Since x.x.x. This constructor leaks the internal Time object.
* Please use the public constructors that do not accept a Time object.
* Internal Kafka components should use {@link MetricsInternalFactory#create(Time)}.
* This constructor will be reduced to package-private visibility in version 5.0.
*/
@Deprecated
@SuppressKafkaInternalApiUsage("KIP-1311: Deprecated and will be hidden in 5.0")
public Metrics(Time time) {
this(new MetricConfig(), new ArrayList<>(0), time);
}
{code}
{code:java}
// Some comments here
public String getFoo()
{
return foo;
}
{code}
> Introduce internal accessor pattern to encapsulate cross-package APIs
> ---------------------------------------------------------------------
>
> Key: KAFKA-20958
> URL: https://issues.apache.org/jira/browse/KAFKA-20958
> Project: Kafka
> Issue Type: Improvement
> Reporter: Chia-Ping Tsai
> Assignee: Chia-Ping Tsai
> Priority: Critical
> Labels: need-kip
>
> Currently, to allow cross-package instantiation or state access for internal Kafka components, we either:
> # Leak internal classes (like Time) in public constructors.
> # Expose properties as protected.
> We should introduce the Internal Accessor / Factory Pattern (using package-private scopes and `@InterfaceAudience.Private` helper classes) to cleanly encapsulate these.
> Subsequently, we will deprecate the leaked public constructors/methods to ensure we can remove them in 5.0.
> related discussion:
> https://lists.apache.org/thread/1kmyqody36dhnzj5ph858zsfpl4qhm7l
> https://github.com/apache/kafka/pull/21337#discussion_r3574009798
--
This message was sent by Atlassian Jira
(v8.20.10#820010)