Skip to content

Commit

Permalink
core,interop-testing: avoid flushing after writing a message in case …
Browse files Browse the repository at this point in the history
…the server returns a single response
  • Loading branch information
amirhadadi authored and ejona86 committed Jun 24, 2022
1 parent 334fc32 commit 7b80954
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion core/src/main/java/io/grpc/internal/ServerCallImpl.java
Expand Up @@ -169,7 +169,9 @@ private void sendMessageInternal(RespT message) {
try {
InputStream resp = method.streamResponse(message);
stream.writeMessage(resp);
stream.flush();
if (!getMethodDescriptor().getType().serverSendsOneMessage()) {
stream.flush();
}
} catch (RuntimeException e) {
close(Status.fromThrowable(e), new Metadata());
} catch (Error e) {
Expand Down
Expand Up @@ -189,7 +189,6 @@ public void sendMessage() {
call.sendMessage(1234L);

verify(stream).writeMessage(isA(InputStream.class));
verify(stream).flush();
}

@Test
Expand Down
Expand Up @@ -347,10 +347,10 @@ public void statsRecorded() throws Exception {
fakeClock.forwardTime(2, SECONDS);
serverCall.sendHeaders(new Metadata());
serverCall.sendMessage(3);
serverCall.close(Status.OK, new Metadata());
call.request(1);
assertInboundMessageRecorded();
assertInboundWireSizeRecorded(1);
serverCall.close(Status.OK, new Metadata());
assertRpcStatusRecorded(Status.Code.OK, 2000, 2);
assertRetryStatsRecorded(1, 0, 10_000);
}
Expand Down

0 comments on commit 7b80954

Please sign in to comment.