File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
core/src/main/java/com/google/net/stubby Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -238,11 +238,14 @@ public void running() {}
238238 private class CallImpl <ReqT , RespT > extends Call <ReqT , RespT > {
239239 private final MethodDescriptor <ReqT , RespT > method ;
240240 private final SerializingExecutor callExecutor ;
241+ private final boolean unaryRequest ;
241242 private ClientStream stream ;
242243
243244 public CallImpl (MethodDescriptor <ReqT , RespT > method , SerializingExecutor executor ) {
244245 this .method = method ;
245246 this .callExecutor = executor ;
247+ this .unaryRequest = method .getType () == MethodType .UNARY
248+ || method .getType () == MethodType .SERVER_STREAMING ;
246249 }
247250
248251 @ Override
@@ -308,7 +311,12 @@ public void sendPayload(ReqT payload) {
308311 cancel ();
309312 }
310313 }
311- stream .flush ();
314+ // For unary requests, we don't flush since we know that halfClose should be coming soon. This
315+ // allows us to piggy-back the END_STREAM=true on the last payload frame without opening the
316+ // possibility of broken applications forgetting to call halfClose without noticing.
317+ if (!unaryRequest ) {
318+ stream .flush ();
319+ }
312320 }
313321
314322 private class ClientStreamListenerImpl implements ClientStreamListener {
You can’t perform that action at this time.
0 commit comments