Skip to main content

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

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