public ByteBuf dumpWrittenAndClose() {
        closed = true;
        return buffer;
    }
Returns current content of the underlying buffer and closes the stream.
This is a terminating methods that could serve an alternative to {@link #flush()} and {@link #close()}.
It allows closing the {@link OutputStream} without flushing the content.
resteasy/src/main/java/com/linecorp/armeria/internal/common/resteasy/ByteBufferBackedOutputStream.java