提交 7763391e 编写于 作者: V Violeta Georgieva

AbstractResponseBodySubscriber improvements

When the thread is writing to the response in
RECEIVED.onWritePossible(), the execution may stop because isReady()
returned false. In this case the buffer is partially written.
When there is partially written case:
1. The state will be changed from WRITING to RECEIVED
2. A check for "write possible" will be performed:
  - If onWritePossible event has been already called by the web
  container while in WRITING state then this check will trigger
  RECEIVED.onWritePossible() because isReady() will be true and the
  writing will continue.
  - Otherwise the writing will be resumed when the web container sends
  onWritePossible event.
上级 55193194
......@@ -101,6 +101,16 @@ abstract class AbstractResponseBodySubscriber implements Subscriber<DataBuffer>
protected void receiveBuffer(DataBuffer dataBuffer) {
Assert.state(this.currentBuffer == null);
this.currentBuffer = dataBuffer;
checkOnWritePossible();
}
/**
* Called when a {@link DataBuffer} is received via {@link Subscriber#onNext(Object)}
* or when only partial data from the {@link DataBuffer} was written.
*/
protected void checkOnWritePossible() {
// no-op
}
/**
......@@ -238,6 +248,7 @@ abstract class AbstractResponseBodySubscriber implements Subscriber<DataBuffer>
}
else {
subscriber.changeState(WRITING, RECEIVED);
subscriber.checkOnWritePossible();
}
}
catch (IOException ex) {
......
......@@ -233,9 +233,7 @@ public class ServletHttpHandlerAdapter extends HttpServlet {
}
@Override
protected void receiveBuffer(DataBuffer dataBuffer) {
super.receiveBuffer(dataBuffer);
protected void checkOnWritePossible() {
try {
if (outputStream().isReady()) {
onWritePossible();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册