Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ final class ServletServerStream extends AbstractServerStream {
this.resp = (HttpServletResponse) asyncCtx.getResponse();
this.writer = new AsyncServletOutputStreamWriter(
asyncCtx, transportState, logId);
// Register before the peer can reset the stream and cause the container to commit the response.
resp.setTrailerFields(sink.trailerSupplier);
resp.getOutputStream().setWriteListener(new GrpcWriteListener());
}

Expand Down Expand Up @@ -231,7 +233,6 @@ private final class Sink implements AbstractServerStream.Sink {
@Override
public void writeHeaders(Metadata headers, boolean flush) {
writeHeadersToServletResponse(headers);
resp.setTrailerFields(trailerSupplier);
try {
writer.flush();
} catch (IOException e) {
Expand Down
Loading