question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Response with type ParameterizedType not working with WebClient

See original GitHub issue

Describe the bug Using spring cloud square 0.4.1

When creating an interface for retrofit and declaring a return type which is a parameterized class doesn’t allow the application to start due to a ClassCastException in WebClientCallAdapterFactory#81 or, if not wrapping inside a Mono/Flux, WebClientCallAdapterFactory#87

The ReactorCallAdapterFactory used in com.jakewharton.retrofit:retrofit2-reactor-adapter allows such things, but then we lose the feature of a fully non-blocking client.

Also trying to use spring-cloud-square-retrofit + spring-cloud-square-okhttp does not work in webflux applications since a HttpMessageConverters bean is not created due to Conditional annotations.

Sample Just create an application with spring webflux and an interface like the following:

@RetrofitClient(name ="whatever")
public interface MyClient {

@GET("/something")
Flux<MyType<MyObject>> getMyTypeWithMyObject();

}

And include in your pom

  • spring-cloud-square-retrofit-webclient
  • spring-boot-starter-webflux

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
michael-wirthcommented, Oct 4, 2022

Hi @OlgaMaciaszek I’d be glad to work on some bug fixes and smaller enhancements. We’re using Square to define a declarative web client. I assume with the migration to Spring 6 we will also go for the new solution.

0reactions
OlgaMaciaszekcommented, Oct 4, 2022

Thanks, @michael-wirth - it will be very helpful. I will definitely get to your PRs, but till the end of Nov work on anything unrelated to the 2022.x release might be slow on our side. We will definitely catch up with other backlogs then, however.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring WebClient with ParameterizedTypeReference doesn't ...
I created the following class to store the API response. @Data @Jacksonized @Builder public class ApiResponse<T> { private ...
Read more >
WebClient does not deserialize ParameterizedTypeReference ...
It will not work if we move that webClient.get() block to a separate function and change it to take generic type like this...
Read more >
Spring 5 WebClient - Baeldung
In order to work properly with the client, we need to know how to: create an instance; make a request; handle the response....
Read more >
Hacking Type Erasure with Super Type Token - Medium
WebClient (Non-blocking, reactive). In both example we are instructing Spring to deserialise the JSON response into a User object by passing in ...
Read more >
Sending HTTP requests with Spring WebClient - Reflectoring
As a reactive API, the request is not actually sent until something attempts to read or wait for the response. How do we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found