Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jersey-dev] Checking client response entity type

Can I get some advice here please?

On Tue, Oct 27, 2020 at 10:17 AM Martynas Jusevičius
<martynas@xxxxxxxxxxxxx> wrote:
>
> Hi,
>
> I have Jersey 2.30.1 client code roughly like this:
>
>     public Response getClientResponse()
>     {
>         return getWebTarget().request(getReadableMediaTypes()).get();
>     }
>
>     ...
>     {
>         try (Response cr = getClientResponse())
>         {
>             if (cr.getEntity() instanceof Model)
>             {
>                 Model model = (Model)cr.getEntity();
>                 ...
>             }
>         ...
>     }
>
> The problem is that sometimes the (cr.getEntity() instanceof Model)
> check fails -- the entity is actually of type
> org.glassfish.jersey.apache.connector.ApacheConnector$ConnectionClosingMechanism$1.
>
> Why is that so and how can I safely check the client response type?
>
> Thanks.
>
>
> Martynas
> atomgraph.com


Back to the top