private KafkaFutureImpl<V> futureOrThrow(K key) {
            // The below typecast is safe because we initialise futures using only KafkaFutureImpl.
            KafkaFutureImpl<V> future = (KafkaFutureImpl<V>) futures.get(key);
            if (future == null) {
                throw new IllegalArgumentException("Attempt to complete future for " + key +
                    ", which was not requested");
            } else {
                return future;
            }
        }
This class can be used when the set of keys is known ahead of time.
clients/src/main/java/org/apache/kafka/clients/admin/internals/AdminApiFuture.java