Skip to content

Considering removing AsyncRequest#inputStream() and AsyncResponse#outputStream() #74

@alalag1

Description

@alalag1

Motivation

AsyncRequest and AsyncResponse provide methods:

  1. AsyncRequest#inputStream() is holding the aggregated body which has been received completely, It doesn't make much sense to do this.
  2. It is hard to be compatible with the InputStream that will block until input data is available, which it may block on the IO EventloopGroup
  3. AsyncResponse#outputStream() is writing bytes asynchronously, which means it is allowed to write bytes very frequently without any check of channel's writability and ByteBufAllocator's allocatability, which may cause an OOM error.
    private void flush(boolean isLast) {
    if (byteBuf.readableBytes() == 0) {
    if (isLast) {
    byteBuf.release();
    }
    return;
    }
    if (isLast) {
    resp.write(byteBuf);
    } else {
    final ByteBuf copy = byteBuf.copy();
    try {
    resp.write(copy);
    } catch (Exception e) {
    copy.release();
    ExceptionUtils.throwException(e);
    } finally {
    byteBuf.clear();
    }
    }
    }
  4. It is hard to be compatible with the OutputStream that will block until output data is writable, which it may block on the IO EventloopGroup
  5. Reactive programing is exactly what we want

What should we do

  1. Remove AsyncRequest#inputStream() and AsyncResponse#outputStream() methods
  2. Supporting reading/writing data reactively

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions