Hi Ismael, Thanks for the reply.
So this is what's described in the KIP but using CompletionStage rather than CompletableFuture, right? And I assume the methods of concern are complete(), and completeExceptionally(), which only the Admin client should be calling, and also obtrudeValue() and obtrudeException() (which basically no one should be calling as far as I can see). As described in the KIP, the motivation in providing a CompletableFuture was for passing to any 3rd party APIs which required it. It's also worth noting that CompletionStage has a this-returning toCompletableFuture() anyway, so we're not really providing any real extra safety here. It's a shame that the JDK didn't define a subinterface of CompletionStage with the useful blocking methods (get(), getNow()) and a completely separate interface for the completion methods so that what we want could be expressed type-safely. What we could do would be to return a subclass of CompletableFuture where those methods (plus minimalCompletionStage()) threw exceptions. I guess it wouldn't have to be a public subclass if KafkaFuture#toCompletableFuture() documented the behaviour of those methods. Even that's not perfect if future API evolution of CompletableFuture added more dangerous methods. Thoughts? Tom On Fri, Mar 19, 2021 at 3:22 PM Ismael Juma <ism...@juma.me.uk> wrote: > Hi Tom, > > I think it makes sense to go with the incremental option. I don't like > CompletableFuture because it exposes a bunch of unsafe methods. Since we're > adding this to `KafkaFuture`, then methods like `get` are already > available. What benefit is there for exposing `CompletableFuture` instead > of `CompletionStage`? > > Ismael > > On Fri, Jan 22, 2021 at 7:02 AM Tom Bentley <tbent...@redhat.com> wrote: > > > Hi, > > > > Following a recent discussion on a PR[1], I've written KIP-707 to > establish > > what should be done to improve the API of KafkaFuture. > > If you have the time, your comments would be most welcome, as some of the > > rejected alternatives are not unreasonable. > > > > > > > https://cwiki.apache.org/confluence/display/KAFKA/KIP-707%3A+The+future+of+KafkaFuture > > > > Many thanks, > > > > Tom > > > > [1]: https://github.com/apache/kafka/pull/9878 > > >