Current state: Under Discussion
Discussion thread: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
This KIP is a 3rd attempt to bring consistency and testability to the Admin client's
*Result classes. It follows two KIPs which were not accepted:
- KIP-692 which proposed to make all the constructors public on the grounds of making it easier to users to write tests with mock
- KIP-774 which proposed to deprecate the existing public constructors (most are currently package-private) and eventually revert them all to package-private, on the grounds of making it easier to evolve the overall Admin API in a compatible way.
The proposal this time is to establish the following convention/pattern for the instantiation of Result classes:
- To evolve using constructor overloading and deprecation where possible (for example, when an API change requires adding a new constructor parameter in addition to an existing one we could deprecate the old constructor delegating to a new constructor passing null for the argument to the added parameter).
public staticfactory methods for API evolution that cannot use overloading (for example if an API change requires changing the type arguments of an existing constructor parameter, which would be impossible to do via constructor overloading while retaining compatibility because the erased signatures of the old and new constructors would be the same).
It is also proposed to:
- Remove the
ElectLeadersResultto improve consistency.
- Add a static
KafkaFuture.failedFuture(Throwable)method for creating failed futures without needing to use the private KafkaFutureImpl class (
KafkaFuturealready has a static
- Change the access modifier of all existing non-deprecated package-private and/or
*Resultclasses in the
- Remove any
finalmodifiers on those classes
Per public interfaces section.
Compatibility, Deprecation, and Migration Plan
This change is source and binary compatible with previous releases.
- Do nothing.
- Follow proposal of KIP-692.
- Follow proposal of KIP-774.
- Change the Result classes to interfaces. This would be quite a bit more code, for similar protection as a package-private constructor and not improve the situation for people mocking the Admin client.