@Override
    public boolean cancel(boolean mayInterruptIfRunning) {
        synchronized (this) {
            if (isDone()) {
                return false;
            }
            if (mayInterruptIfRunning) {
                this.cancelled = true;
                finishedLatch.countDown();
                return true;
            }
        }
        try {
            finishedLatch.await();
        } catch (InterruptedException e) {
            throw new ConnectException("Interrupted while waiting for task to complete", e);
        }
        return false;
    }
An abstract implementation of {@link Callback} that also implements the {@link Future} interface. This allows for
operations like waiting until the callback is completed via {@link #onCompletion(Throwable, Object)}. The result
from the callback can be converted by concrete implementations of this class before being retrieved via
{@link Future#get}.
@param <U> the callback result type
@param <T> the future result type obtained after converting the callback result
connect/runtime/src/main/java/org/apache/kafka/connect/util/ConvertingFutureCallback.java