Fix workaround in place for GFE's lack of trailers.

A recent refactoring moved code so our previous workaround stopped
producing any effect.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79965647
This commit is contained in:
ejona 2014-11-14 12:46:39 -08:00 committed by Eric Anderson
parent 0f56c47ac8
commit 01152e093d
2 changed files with 14 additions and 12 deletions

View File

@ -186,14 +186,6 @@ public abstract class AbstractClientStream<IdT> extends AbstractStream<IdT>
@Override
protected void remoteEndClosed() {
// TODO(user): Delete this hack when trailers are supported by GFE with v2. Currently GFE
// doesn't support trailers, so when using gRPC v2 protocol GFE will not send any status. We
// paper over this for now by just assuming OK. For all properly functioning servers (both v1
// and v2), stashedStatus should not be null here.
if (stashedStatus == null) {
stashedStatus = Status.OK;
stashedTrailers = new Metadata.Trailers();
}
Preconditions.checkState(stashedStatus != null, "Status and trailers should have been set");
setStatus(stashedStatus, stashedTrailers);
}

View File

@ -105,10 +105,20 @@ public abstract class Http2ClientStream extends AbstractClientStream<Integer> {
}
} else {
if (endOfStream && GRPC_V2_PROTOCOL) {
// This is a protocol violation as we expect to receive trailers.
transportError = Status.INTERNAL.withDescription("Recevied EOS on DATA frame");
frame.close();
inboundTransportError(transportError);
if (false) {
// This is a protocol violation as we expect to receive trailers.
transportError = Status.INTERNAL.withDescription("Recevied EOS on DATA frame");
frame.close();
inboundTransportError(transportError);
} else {
// TODO(user): Delete this hack when trailers are supported by GFE with v2. Currently GFE
// doesn't support trailers, so when using gRPC v2 protocol GFE will not send any status.
// We paper over this for now by just assuming OK. For all properly functioning servers
// (both v1 and v2), stashedStatus should not be null here.
Metadata.Trailers trailers = new Metadata.Trailers();
trailers.put(Status.CODE_KEY, Status.OK);
inboundTrailersReceived(trailers, Status.OK);
}
} else {
inboundDataReceived(frame);
if (endOfStream && !GRPC_V2_PROTOCOL) {