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

I believe ApacheConnector$ConnectionClosingMechanism$1 is an InputStream, so instead of getEntity, you'd better use readEntity.

On 31.10.2020 14:48, Martynas Jusevičius wrote:
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
_______________________________________________
jersey-dev mailing list
jersey-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://urldefense.com/v3/__https://www.eclipse.org/mailman/listinfo/jersey-dev__;!!GqivPVa7Brio!KbdIEOrv27h3DDSLD7NSKFyw3JAJSdLZjCYOZIQDahKpZI2ooyJr8loKDTAADETq$


Back to the top