final boolean failIfStreamOrSessionClosed() {
        // Make sure that a stream exists before writing data.
        // 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, the listener requests next data and
        //    the subscriber attempts to write the next data to the stream closed at 2).
        if (!isWritable()) {
            Throwable cause = null;
            final RequestLog requestLog = reqCtx.log().getIfAvailable(RequestLogProperty.RESPONSE_CAUSE);
            if (requestLog != null) {
                cause = requestLog.responseCause();
            }
            if (cause == null) {
                if (reqCtx.sessionProtocol().isMultiplex()) {
                    cause = ClosedStreamException.get();
                } else {
                    cause = ClosedSessionException.get();
                }
            }
            fail(cause);
            return true;
        }
        return false;
    }
Fails a request and a response with the specified {@link Throwable}.
This method won't send any response to the remote peer but log the failed request.
core/src/main/java/com/linecorp/armeria/server/AbstractHttpResponseHandler.java