private synchronized void dispatchChunk() {
            if (cancelled) {
                return;
            }
            try {
                // Pop off the next chunk and send it to the client.
                final Chunk chunk = chunks.remove();
                if (chunk == completionChunk) {
                    responseStream.onCompleted();
                } else {
                    responseStream.onNext(chunk.toResponse());
                }
            } catch (Throwable e) {
                failure = e;
                if (GrpcExceptionHandlerFunction.of()
                                                .apply(ServiceRequestContext.current(), Status.UNKNOWN,
                                                       e, new Metadata())
                                                .getCode() == Status.CANCELLED.getCode()) {
                    // Stream was cancelled by client, responseStream.onError() might be called already or
                    // will be called soon by inbounding StreamObserver.
                    chunks.clear();
                } else {
                    responseStream.onError(e);
                }
            }
        }
Dispatches the current response chunk to the client. This is only called by the executor. At
any time, a given dispatch task should only be registered with the executor once.
grpc/src/test/java/com/linecorp/armeria/internal/common/grpc/TestServiceImpl.java