Rest Client Error when getting body content when an error

1,210 views
Skip to first unread message

Alex Soto Bueno

unread,
Dec 9, 2021, 8:19:11 AM12/9/21
to Quarkus Development mailing list
Hi, I'm developing a very simple Rest Client API that makes a call to an external service. This external service might return a HTTP 500 error code but with body content.

If I execute the call using curl I got the following thing:

curl bubble-backend:8080/bubble -v

*   Trying 172.30.5.96:8080...
* TCP_NODELAY set
* Connected to bubble-backend (172.30.5.96) port 8080 (#0)
> GET /bubble HTTP/1.1
> Host: bubble-backend:8080
> User-Agent: curl/7.67.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< content-type: application/json
< content-length: 80
< x-envoy-upstream-service-time: 4
< date: Thu, 09 Dec 2021 12:56:15 GMT
< server: envoy
<
* Connection #0 to host bubble-backend left intact
{"color":"yellow","hostname":"bubblebackend-v1-dd5bf5754-wx854","requests":1539}


So as you can see the external service is returning correctly the 500 server error and with body content.

Then in Rest Client, I have the following code (the code is a bit redundant but I am trying different things):

try {
JsonObject bubble = bubbleService.bubble();
statistics.add(bubble);
return bubble;
} catch(WebApplicationException e) {
System.out.println(e.getResponse().readEntity(JsonObject.class));
JsonObject bubble = (JsonObject) e.getResponse().getEntity();
statistics.add(bubble);
return bubble;
}

The exception is thrown correctly but when I try to read the entity I got:

Caused by: java.lang.IllegalStateException: RESTEASY003291: Input stream was empty, there is no entity
        at org.jboss.resteasy.specimpl.BuiltResponse.readFrom(BuiltResponse.java:147)
        ... 32 more



In theory, there should be a body content but the exception that is thrown is that it is empty.

Any idea?

Max Rydahl Andersen

unread,
Dec 11, 2021, 4:40:17 PM12/11/21
to Alex Soto Bueno, Quarkus Development mailing list

Hi Alex :)

This list is for discussing development of Quarkus and it's extensions.
Your question sounds like it is more a question of how to use Quarkus in an application.

To make sure user questions and answers are easy to locate
please use https://github.com/quarkusio/quarkus/discussions or Stack Overflow to
ask Quarkus usage questions.

I encourage you to post the link to your question/post when you have it.

If you still think your question is more about Quarkus development then please follow
up with further details to clarify.

Thank you for using Quarkus!

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/e61948d3-094b-4c5a-83dd-5d45d31032e5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages