Skip to content

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
velo added a commit that referenced this pull request Oct 7, 2024
* Advanced parametrized type resolution for AsyncFeign

* Formatting fix

Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
velo added a commit that referenced this pull request Oct 8, 2024
* Advanced parametrized type resolution for AsyncFeign

* Formatting fix

Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
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.

2 participants