@Override
    public void write(int b) throws IOException {
        if (closed) {
            throw new IllegalStateException("Already closed");
        }
        if (buffer.isWritable()) {
            buffer.writeByte(b);
        } else {
            flush();
            write(b);
        }
    }
An {@link OutputStream} that uses {@link ByteBuf} to accumulate stream data before flushing to the
designated {@link Consumer}.
resteasy/src/main/java/com/linecorp/armeria/internal/common/resteasy/ByteBufferBackedOutputStream.java