Status

Current state: Under Discussion

Discussion thread: here

JIRA: KAFKA-13285

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

The *Result classes returned by the Admin client originally had package access constructors. This allowed these constructors to be changed without needing to reason about compatibility, since client code could not directly instantiate these classes.

Over time a minority of the Result classes have ended up with public constructors. So there is an inconsistency in these classes. This caused a problem in the Kafka 3.0 development cycle because a couple of constructor signatures were changed, but one of those constructors was public, which was missed in the original code review.

So to have a consistent API and avoid similar problems in the future the inconsistency ought to be resolved, either by making all the constructors public or or all package access.

KIP-692 proposed to make all these constructors public, using the rationale that it simplifies the creation of mock Admin clients for testing. Note that when the vote for KIP-692 was called it was done on the [DISCUSS] thread, so the lack of votes might not be an sure indication of how the community feels about it.

This KIP proposes taking a step in the opposite direction: To deprecate the public use of these constructors and eventually to make them package access.

Trade off is:

Public Interfaces

Deprecate the public use of the constructors of the following classes:

Also, remove the final modifier from ElectLeadersResult. This prevents the instantiation of mocks by frameworks such as Mockito, and appear to confer no safety on the use of the result class.

Proposed Changes

Per public interfaces section.

Compatibility, Deprecation, and Migration Plan

The constructors will become package access in a future major release. Existing out-of-package callers will need to use mock libraries or reflection to instantiate these classes. The only anticipated existing out-of-package callers are in other project's test code.

Rejected Alternatives