Fixed Servlet flush
Servlet flush will now occur on the next possible write if it cannot be done immediately.
This commit is contained in:
committed by
Sebastien Deleuze
parent
9004812231
commit
81496624a9
@@ -247,8 +247,11 @@ public class ServletHttpHandlerAdapter extends HttpServlet {
|
||||
|
||||
private volatile boolean completed = false;
|
||||
|
||||
private volatile boolean flushOnNext = false;
|
||||
|
||||
private Subscription subscription;
|
||||
|
||||
|
||||
public ResponseBodySubscriber(ServletAsyncContextSynchronizer synchronizer,
|
||||
int bufferSize) {
|
||||
this.synchronizer = synchronizer;
|
||||
@@ -321,6 +324,12 @@ public class ServletHttpHandlerAdapter extends HttpServlet {
|
||||
ServletOutputStream output = synchronizer.getResponse().getOutputStream();
|
||||
|
||||
boolean ready = output.isReady();
|
||||
|
||||
if (flushOnNext) {
|
||||
flush(output);
|
||||
ready = output.isReady();
|
||||
}
|
||||
|
||||
logger.trace("ready: " + ready + " buffer: " + dataBuffer);
|
||||
|
||||
if (ready) {
|
||||
@@ -370,9 +379,12 @@ public class ServletHttpHandlerAdapter extends HttpServlet {
|
||||
logger.trace("Flushing");
|
||||
try {
|
||||
output.flush();
|
||||
flushOnNext = false;
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
} else {
|
||||
flushOnNext = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user