mirror of https://github.com/grpc/grpc-java.git
core: always call StreamTracer.streamClosed() when stream is officially closed. (#4331)
Previously StreamTracer.streamClosed() is called in ServerStream.close(), but it is not exactly when the stream is officially closed. ServerStreamListener.closed() is guaranteed to be called and it is the official end of the stream.
This commit is contained in:
parent
7c46bd9399
commit
3f63cd0ad4
|
@ -128,7 +128,6 @@ public abstract class AbstractServerStream extends AbstractStream
|
|||
Preconditions.checkNotNull(trailers, "trailers");
|
||||
if (!outboundClosed) {
|
||||
outboundClosed = true;
|
||||
statsTraceCtx.streamClosed(status);
|
||||
endOfMessages();
|
||||
addStatusToTrailers(trailers, status);
|
||||
// Safe to set without synchronization because access is tightly controlled.
|
||||
|
@ -336,6 +335,7 @@ public abstract class AbstractServerStream extends AbstractStream
|
|||
statsTraceCtx.streamClosed(newStatus);
|
||||
getTransportTracer().reportStreamClosed(false);
|
||||
} else {
|
||||
statsTraceCtx.streamClosed(closedStatus);
|
||||
getTransportTracer().reportStreamClosed(closedStatus.isOk());
|
||||
}
|
||||
listenerClosed = true;
|
||||
|
|
|
@ -776,10 +776,10 @@ public abstract class AbstractTransportTest {
|
|||
trailers.put(asciiKey, "dupvalue");
|
||||
trailers.put(binaryKey, "äbinarytrailers");
|
||||
serverStream.close(status, trailers);
|
||||
assertSame(status, serverStreamTracer1.getStatus());
|
||||
assertNull(serverStreamTracer1.nextInboundEvent());
|
||||
assertNull(serverStreamTracer1.nextOutboundEvent());
|
||||
assertCodeEquals(Status.OK, serverStreamListener.status.get(TIMEOUT_MS, TimeUnit.MILLISECONDS));
|
||||
assertSame(status, serverStreamTracer1.getStatus());
|
||||
Status clientStreamStatus = clientStreamListener.status.get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
Metadata clientStreamTrailers =
|
||||
clientStreamListener.trailers.get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
|
|
Loading…
Reference in New Issue