@Override
  public void callMethod(MethodDescriptor method, RpcController controller, Message request,
    Message responsePrototype, RpcCallback<Message> done) {
    final Context context = Context.current();
    addListener(conn.callerFactory.<Message> single().table(tableName).row(row)
      .locateType(RegionLocateType.CURRENT).rpcTimeout(rpcTimeoutNs, TimeUnit.NANOSECONDS)
      .operationTimeout(operationTimeoutNs, TimeUnit.NANOSECONDS).action((c, l, s) -> {
        try (Scope ignored = context.makeCurrent()) {
          return rpcCall(method, request, responsePrototype, c, l, s);
        }
      }).call(), (r, e) -> {
        try (Scope ignored = context.makeCurrent()) {
          if (e != null) {
            setCoprocessorError(controller, e);
          }
          done.run(r);
        }
      });
  }
The implementation of a region based coprocessor rpc channel.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionCoprocessorRpcChannelImpl.java