Program: 15269
Project: 15269
Buggy source:
/** 
 * This sets as span in scope both for the interception and for the start of the request. It does not set a span in scope during the response listener as it is unexpected it would be used at that fine granularity. If users want access to the span in a response listener, they will need to wrap the executor with one that's aware of the current context.
 */
@Override public <ReqT,RespT>ClientCall<ReqT,RespT> interceptCall(final MethodDescriptor<ReqT,RespT> method,final CallOptions callOptions,final Channel next){
  Span span=tracer.nextSpan();
  try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
    return new SimpleForwardingClientCall<ReqT,RespT>(next.newCall(method,callOptions)){
      @Override public void start(      Listener<RespT> responseListener,      Metadata headers){
        injector.inject(span.context(),headers);
        span.kind(Span.Kind.CLIENT).start();
        parser.onStart(method,callOptions,headers,span);
        try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
          super.start(new SimpleForwardingClientCallListener<RespT>(responseListener){
            @Override public void onMessage(            RespT message){
              try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
                parser.onMessageReceived(message,span);
                delegate().onMessage(message);
              }
             }
            @Override public void onClose(            Status status,            Metadata trailers){
              try {
                super.onClose(status,trailers);
                parser.onClose(status,trailers,span);
              }
  finally {
                span.finish();
              }
            }
          }
,headers);
        }
       }
      @Override public void sendMessage(      ReqT message){
        super.sendMessage(message);
        parser.onMessageSent(message,span);
      }
    }
;
  }
 catch (  RuntimeException|Error e) {
    parser.onError(e,span);
    span.finish();
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * This sets as span in scope both for the interception and for the start of the request. It does not set a span in scope during the response listener as it is unexpected it would be used at that fine granularity. If users want access to the span in a response listener, they will need to wrap the executor with one that's aware of the current context.
 */
@Override public <ReqT,RespT>ClientCall<ReqT,RespT> interceptCall(final MethodDescriptor<ReqT,RespT> method,final CallOptions callOptions,final Channel next){
  Span span=tracer.nextSpan();
  try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
    return new SimpleForwardingClientCall<ReqT,RespT>(next.newCall(method,callOptions)){
      @Override public void start(      Listener<RespT> responseListener,      Metadata headers){
        injector.inject(span.context(),headers);
        span.kind(Span.Kind.CLIENT).start();
        try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
          parser.onStart(method,callOptions,headers,span);
          super.start(new SimpleForwardingClientCallListener<RespT>(responseListener){
            @Override public void onMessage(            RespT message){
              try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
                parser.onMessageReceived(message,span);
                delegate().onMessage(message);
              }
             }
            @Override public void onClose(            Status status,            Metadata trailers){
              try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
                super.onClose(status,trailers);
                parser.onClose(status,trailers,span);
              }
  finally {
                span.finish();
              }
            }
          }
,headers);
        }
       }
      @Override public void sendMessage(      ReqT message){
        try (Tracer.SpanInScope ws=tracer.withSpanInScope(span)){
          super.sendMessage(message);
          parser.onMessageSent(message,span);
        }
       }
    }
;
  }
 catch (  RuntimeException|Error e) {
    parser.onError(e,span);
    span.finish();
    throw e;
  }
}