private boolean isStreamOrSessionClosed() {
        // Make sure that a stream exists before writing data if first bytes were transferred.
        // The following situation may cause the data to be written to a closed stream.
        // 1. A connection that has pending outbound buffers receives GOAWAY frame.
        // 2. AbstractHttp2ConnectionHandler.close() clears and flushes all active streams.
        // 3. After successfully flushing, operationComplete() requests next data and
        //    the subscriber attempts to write the next data to the stream closed at 2).
        if (!encoder.isWritable(id, streamId())) {
            if (ctx.sessionProtocol().isMultiplex()) {
                failAndReset(newClosedStreamException(ch));
            } else {
                failAndReset(newClosedSessionException(ch));
            }
            return true;
        }
        return false;
    }
Writes the {@link HttpHeaders trailers} to the {@link Channel}.
Note that the written data is not flushed by this method. The caller should explicitly call
{@link Channel#flush()} when each write unit is done.
core/src/main/java/com/linecorp/armeria/client/AbstractHttpRequestHandler.java