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

AsyncFeign doesn't work with type parameters on the base api interface. #1612

Closed
voron86 opened this issue Apr 29, 2022 · 1 comment
Closed

Comments

@voron86
Copy link

voron86 commented Apr 29, 2022

I tried to use next interface with AsyncFeign:

@Headers({ "Content-Type: application/json", "Accept: application/json" })
public interface V1AsyncEndpoint<T> {

  @RequestLine("POST /api/v1/projects/{project}/{resource}/byids")
  @Headers("Authorization: Bearer {token}")
  CompletableFuture<T> getPageByIds(
      @Param("token") String token,
      @Param("project") String project,
      @Param("resource") String resource,
      @Param("items") Collection<Long> ids,
      @Param("ignoreUnknownIds") boolean ignoreUnknownIds,
      @Nullable
      @Param("aggregatedProperties") Collection<String> aggregatedProperties);
}

for Type:

class Data {
String a;
Long b;
}

But getPageByIds always returns com.google.gson.internal.LinkedTreeMap and then I get java.util.concurrent.CompletionException: java.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap

If I use

@Headers({ "Content-Type: application/json", "Accept: application/json" })
public interface V1AsyncEndpoint {

  @RequestLine("POST /api/v1/projects/{project}/{resource}/byids")
  @Headers("Authorization: Bearer {token}")
  CompletableFuture<Data> getPageByIds(
      @Param("token") String token,
      @Param("project") String project,
      @Param("resource") String resource,
      @Param("items") Collection<Long> ids,
      @Param("ignoreUnknownIds") boolean ignoreUnknownIds,
      @Nullable
      @Param("aggregatedProperties") Collection<String> aggregatedProperties);
}

everything works correctly.

I've made short debugging and I noticed the AsyncFeign decoder gets T as type instead of Data when deserialisation happens.

I use version: 11.8

@voron86
Copy link
Author

voron86 commented Jul 1, 2022

Fixed in 11.9 (#1623)

@voron86 voron86 closed this as completed Jul 1, 2022
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

No branches or pull requests

1 participant