private int read(Function<ByteBuf, Integer> reader) throws IOException {
        try {
            ByteBuf buffer = buffer();
            if (buffer == null) {
                return -1;
            }
            int b;
            while (buffer != null) {
                b = reader.apply(buffer);
                if (b == -1) {
                    // no more data available in the current buffer
                    buffer = next();
                } else {
                    return b;
                }
            }
            return -1; // there is no more data and there are no more byte buffers
        } catch (InterruptedException e) {
            final InterruptedIOException ioe = new InterruptedIOException();
            ioe.initCause(e);
            throw ioe;
        }
    }
Closes this {@link InputStream} and releases any system resources associated with the stream.
Sets EOS, if it has not been set yet. Drains all the allocated buffers.
core/src/main/java/com/linecorp/armeria/internal/common/stream/ByteBufsInputStream.java