From 951083f79189135d818c074224ddc9be76f99565 Mon Sep 17 00:00:00 2001 From: Donghyeon Kim Date: Tue, 20 Sep 2022 14:23:20 +0900 Subject: [PATCH] Add methodInfoResolver attribute to Coroutinebuilder (#1762) * Add methodInfoResolver attribute to Coroutinebuilder Work on the [feedback](https://github.com/OpenFeign/feign/pull/1754#discussion_r974700238) of PR #1754 --- kotlin/src/main/java/feign/kotlin/CoroutineFeign.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kotlin/src/main/java/feign/kotlin/CoroutineFeign.java b/kotlin/src/main/java/feign/kotlin/CoroutineFeign.java index 259dea67f2..a147ef579e 100644 --- a/kotlin/src/main/java/feign/kotlin/CoroutineFeign.java +++ b/kotlin/src/main/java/feign/kotlin/CoroutineFeign.java @@ -19,6 +19,7 @@ import feign.BaseBuilder; import feign.Client; import feign.Experimental; +import feign.MethodInfoResolver; import feign.Target; import feign.Target.HardCodedTarget; import java.lang.reflect.InvocationHandler; @@ -116,6 +117,7 @@ public static class CoroutineBuilder extends BaseBuilder> private AsyncContextSupplier defaultContextSupplier = () -> null; private AsyncClient client = new AsyncClient.Default<>( new Client.Default(null, null), LazyInitializedExecutorService.instance); + private MethodInfoResolver methodInfoResolver = KotlinMethodInfo::createInstance; @Deprecated public CoroutineBuilder defaultContextSupplier(Supplier supplier) { @@ -133,6 +135,11 @@ public CoroutineBuilder defaultContextSupplier(AsyncContextSupplier suppli return this; } + public CoroutineBuilder methodInfoResolver(MethodInfoResolver methodInfoResolver) { + this.methodInfoResolver = methodInfoResolver; + return this; + } + public T target(Class apiType, String url) { return target(new HardCodedTarget<>(apiType, url)); } @@ -167,7 +174,7 @@ public CoroutineFeign build() { .responseInterceptor(responseInterceptor) .invocationHandlerFactory(invocationHandlerFactory) .defaultContextSupplier((AsyncContextSupplier) defaultContextSupplier) - .methodInfoResolver(KotlinMethodInfo::createInstance) + .methodInfoResolver(methodInfoResolver) .build(); return new CoroutineFeign<>(asyncFeign); }