Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced parametrized type resolution for AsyncFeign #1623

Merged
merged 3 commits into from
Jun 13, 2022
Merged

Advanced parametrized type resolution for AsyncFeign #1623

merged 3 commits into from
Jun 13, 2022

Conversation

edudar
Copy link
Contributor

@edudar edudar commented Jun 1, 2022

I've faced an issue that AsyncFeign does not resolve generic parameters correctly when clients are also parametrized — for example, sync and async with a common parameterized interface for return types.

public interface TestClient<T> {
  @RequestLine("GET /log") T log();
}

public interface TestSyncClient extends TestClient<String> {}
public interface TestAsyncClient extends TestClient<CompletableFuture<String>> {}

Feign works just fine:

Feign.builder()
  .target(TestSyncClient.class, url)
  .log();

But AsyncFeign fails

AsyncFeign.asyncBuilder()
  .target(TestAsyncClient.class, url)
  .log()
  .get(); => T is not a type supported by this decoder.

I traced this down to MethodInfo where it does very basic detection unlike Contract.parseAndValidateMetadata() which is used by Feign to create an invocation handler.

The solution I propose is to use the same type-resolution that Contract does here inside MethodInfo.

@velo velo merged commit 3042e52 into OpenFeign:master Jun 13, 2022
@edudar edudar deleted the generic-return-type-async-feign branch June 13, 2022 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants