class SingleLockableSubscriber<T> implements Subscriber<T> {

    @Nullable
    private T value;

    @Nullable
    private Throwable error;

    private final CountDownLatch latch = new CountDownLatch(1);

    @Override
    public void onSubscribe(Subscription subscription) {
        subscription.request(1);
    }

    @Override
    public void onNext(T document) {
        value = document;
    }

    @Override
    public void onError(Throwable throwable) {
        this.error = throwable;
        onComplete();
    }

    @Override
    public void onComplete() {
        latch.countDown();
    }

    @Nullable
    T getValue() {
        return value;
    }

    @Nullable
    Throwable getError() {
        return error;
    }

    void await() {<FILL_FUNCTION_BODY>}
}

        try {
            int timeout = 20;
            if (!latch.await(timeout, TimeUnit.SECONDS)) {
                this.error = new TimeoutException("Did not get response in " + timeout + " seconds.");
            }
        } catch (InterruptedException e) {
            this.error = e;
        }
    
<no_super_class>