Publisher<?> invokeMethod(MethodHandler methodHandler, Object[] arguments) {
    return subscriber ->
        subscriber.onSubscribe(
            new Subscription() {
              private final AtomicBoolean isTerminated = new AtomicBoolean(false);

              @Override
              public void request(long n) {
                if (n <= 0 && !terminated()) {
                  subscriber.onError(new IllegalArgumentException("negative subscription request"));
                }
                if (!isTerminated()) {
                  try {
                    Object result = methodHandler.invoke(arguments);
                    if (null != result) {
                      subscriber.onNext(result);
                    }
                  } catch (Throwable th) {
                    if (!terminated()) {
                      subscriber.onError(th);
                    }
                  }
                }
                if (!terminated()) {
                  subscriber.onComplete();
                }
              }

              @Override
              public void cancel() {
                isTerminated.set(true);
              }

              private boolean isTerminated() {
                return isTerminated.get();
              }

              private boolean terminated() {
                return isTerminated.getAndSet(true);
              }
            });
  }
Invoke the Method Handler as a Publisher.

@param methodHandler to invoke
@param arguments for the method
@return a Publisher wrapper for the invocation.
reactive/src/main/java/feign/reactive/ReactiveInvocationHandler.java