benchmarks: reset context in AsyncClient to avoid chaining.

Fixes #1878
This commit is contained in:
Carl Mastrangelo 2016-06-02 14:33:24 -07:00
parent c6fd94ca85
commit 0021e063f2
1 changed files with 10 additions and 4 deletions

View File

@ -54,6 +54,7 @@ import com.google.common.base.Preconditions;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import io.grpc.Channel; import io.grpc.Channel;
import io.grpc.Context;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.benchmarks.proto.BenchmarkServiceGrpc; import io.grpc.benchmarks.proto.BenchmarkServiceGrpc;
@ -198,10 +199,15 @@ public class AsyncClient {
histogram.recordValue((now - lastCall) / 1000); histogram.recordValue((now - lastCall) / 1000);
lastCall = now; lastCall = now;
if (endTime > now) { Context prevCtx = Context.ROOT.attach();
stub.unaryCall(request, this); try {
} else { if (endTime > now) {
future.done(); stub.unaryCall(request, this);
} else {
future.done();
}
} finally {
Context.current().detach(prevCtx);
} }
} }
}); });