-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
When using reactive restclient in 2.8.2.Final with Response, getEntity() returns null even if there is a body in Response #25496
Comments
I got the same error using Quarkus 2.14.3.Final |
Facing the same issue here... I opened a question on stack overflow about it: |
What happened with me was that the response was actually somehow available inside the callback, since I could print its headers and the status code, and also the endpoint would give me back the full response, but I couldn't access (or print) the body of the response inside the callback... It happens when you have an Uni<Response> object. |
Note that HTTP is made in a way that the headers are received first and the body possibly later (and then trailers, if any). \CC @Sgitario |
This still occurs in Quarkus 3.8.5 (current LTS), a current reproducer available at https://github.com/autumnfound/quarkus-25496-reproducer. If you cast the response and use the entity stream or have a direct type to cast to, you can get around the error, but then have to manually handle streaming unicode characters and list support can get sticky in casting cases. |
There is a consequence of this behavior in #41887, which makes |
Describe the bug
In 2.7.2 using the old restclient and a call with signature
so I could do some work with headers before touching the entity data.
Old code then would ask for an InputStream using response.getEntity() which worked fine.
Reactive restclient will return null in the same situation. I can get the body by doing String data=response.readEntity(String.class) however so there is an entity.
Expected behavior
When restclient returns Uni and there is proper data in the Response, response.getEntity() should return an InputStream.
Actual behavior
In Quarkus 2.8.2, when calling response.getEntity(), null is returned, indicating that the response does not have an entity.
How to Reproduce?
Steps:
1: Compile and start backing web service "restservice", runs on localhost port 8080
2: Compile and start service that uses 2.8.2.Final reactive restclient "restclient", runs on localhost port 8088
3: Compile and run service that uses 2.7.2.Final nonreactive restclient, runs on localhost port 8098
4: Trigger either rest client by using
curl http://localhost:8088/hello/response
orcurl http://localhost:8098/hello/response
You'll get a canned response from the call, but in the restclient service logs you'll see the differing behaviour of getEntity()
restclient_response_reproduced.zip
.
Output of
uname -a
orver
Linux deadpool 5.13.0-40-generic #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "18.0.1" 2022-04-19 OpenJDK Runtime Environment Zulu18.30+11-CA (build 18.0.1+10) OpenJDK 64-Bit Server VM Zulu18.30+11-CA (build 18.0.1+10, mixed mode, sharing)
GraalVM version (if different from Java)
N/A
Quarkus version or git rev
2.8.2
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Additional information
No response
The text was updated successfully, but these errors were encountered: