mirror of https://github.com/grpc/grpc-java.git
Support early-OK from Server.
The semantics in gRPC changed where server sending OK before client half-closes is now permitted. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=78404390
This commit is contained in:
parent
0a585333ce
commit
df9867def9
|
@ -75,8 +75,6 @@ public abstract class AbstractServerStream extends AbstractStream implements Ser
|
|||
Preconditions.checkNotNull(trailers, "trailers");
|
||||
outboundPhase(Phase.STATUS);
|
||||
synchronized (stateLock) {
|
||||
Preconditions.checkState(!status.isOk() || state == WRITE_ONLY,
|
||||
"Cannot close with OK before client half-closes");
|
||||
state = CLOSED;
|
||||
}
|
||||
gracefulClose = true;
|
||||
|
|
|
@ -67,13 +67,15 @@ public class NettyServerStreamTest extends NettyStreamTestBase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void closeBeforeClientHalfCloseShouldFail() {
|
||||
try {
|
||||
stream().close(Status.OK, new Metadata.Trailers());
|
||||
fail("Should throw exception");
|
||||
} catch (IllegalStateException expected) {
|
||||
}
|
||||
assertEquals(StreamState.OPEN, stream.state());
|
||||
public void closeBeforeClientHalfCloseShouldSucceed() throws Exception {
|
||||
stream().close(Status.OK, new Metadata.Trailers());
|
||||
verify(channel).writeAndFlush(
|
||||
new SendGrpcFrameCommand(STREAM_ID, statusFrame(Status.OK), true));
|
||||
verifyZeroInteractions(serverListener);
|
||||
// Sending complete. Listener gets closed()
|
||||
stream().complete();
|
||||
verify(serverListener).closed(Status.OK);
|
||||
assertEquals(StreamState.CLOSED, stream.state());
|
||||
verifyZeroInteractions(serverListener);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue