From 01152e093d0c627af64f5dd192e8377b61fa0ccb Mon Sep 17 00:00:00 2001 From: ejona Date: Fri, 14 Nov 2014 12:46:39 -0800 Subject: [PATCH] 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 --- .../stubby/transport/AbstractClientStream.java | 8 -------- .../stubby/transport/Http2ClientStream.java | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/google/net/stubby/transport/AbstractClientStream.java b/core/src/main/java/com/google/net/stubby/transport/AbstractClientStream.java index f0cfffa719..e4aa7e1c94 100644 --- a/core/src/main/java/com/google/net/stubby/transport/AbstractClientStream.java +++ b/core/src/main/java/com/google/net/stubby/transport/AbstractClientStream.java @@ -186,14 +186,6 @@ public abstract class AbstractClientStream extends AbstractStream @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); } diff --git a/core/src/main/java/com/google/net/stubby/transport/Http2ClientStream.java b/core/src/main/java/com/google/net/stubby/transport/Http2ClientStream.java index 8d850500d1..712b439a9c 100644 --- a/core/src/main/java/com/google/net/stubby/transport/Http2ClientStream.java +++ b/core/src/main/java/com/google/net/stubby/transport/Http2ClientStream.java @@ -105,10 +105,20 @@ public abstract class Http2ClientStream extends AbstractClientStream { } } 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) {