quarkus: Response Body in ClientExceptionMapper is always null
Describe the bug
We implemented a REST-Client using the quarkus-rest-client-reactive dependency.
For this client we added custom exception handling using the @ClientExceptionMapper annotation.
There we could read the body of the response.
e.g.:
@ClientExceptionMapper
static ServiceException handle(Response response) {
response.bufferEntity();
Error error = response.readEntity(Error.class);
return new ServiceException(error.getReason(), error.getMessage(), response.getStatus());
}
Now with the new version the entity object is always null. (So error.getMessag will throw a NullPointerException) (Also if we jus handle the WebApplicationException we can’t read the body because its null) For the status everything works fine.
This works for quarkus-plattform version 2.13.3 but not in version 2.14.1.
Expected behavior
The error object should be the parsed (json-)-response-object.
Actual behavior
The error object is null because the entity of response is null.
How to Reproduce?
- Create a rest-client
- Make a request that will fail (400, 404, …)
- Handle the custom/WebApplicationException
- read the response body from the exception
Output of uname -a or ver
No response
Output of java -version
openjdk version “17.0.2” 2022-01-18 OpenJDK Runtime Environment (build 17.0.2+8-86) OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version or gradlew --version)
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (11 by maintainers)
After having another look at the changes in https://github.com/quarkusio/quarkus/pull/29119, this fixes the following issue https://github.com/quarkusio/quarkus/issues/28818 which only happens when the body is large (the server takes a time to fully read the large body and hence not releasing the client connection until is fully read).
Therefore, I think we should revert the changes in https://github.com/quarkusio/quarkus/pull/29119 and update the issue https://github.com/quarkusio/quarkus/issues/28818 to state that this happens when you use a large body.
Wdyt? @geoand