-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
refactorCode changeCode change
Description
Motivation
AsyncRequest and AsyncResponse provide methods:
esa-restlight/restlight-server-adapter/src/main/java/esa/httpserver/core/AsyncRequest.java
Line 101 in 56f13c1
| HttpInputStream inputStream(); |
esa-restlight/restlight-server-adapter/src/main/java/esa/httpserver/core/AsyncResponse.java
Line 75 in 56f13c1
| HttpOutputStream outputStream(); |
AsyncRequest#inputStream()is holding the aggregated body which has been received completely, It doesn't make much sense to do this.- It is hard to be compatible with the
InputStreamthat will block until input data is available, which it may block on the IO EventloopGroup AsyncResponse#outputStream()is writing bytes asynchronously, which means it is allowed to write bytes very frequently without any check of channel's writability andByteBufAllocator's allocatability, which may cause an OOM error.
Lines 203 to 224 in 56f13c1
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(); } } } - It is hard to be compatible with the
OutputStreamthat will block until output data is writable, which it may block on the IO EventloopGroup Reactive programingis exactly what we want
What should we do
- Remove AsyncRequest#inputStream() and AsyncResponse#outputStream() methods
- Supporting reading/writing data reactively
Metadata
Metadata
Assignees
Labels
refactorCode changeCode change