jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] ClientException or MessageProcessingException when no MBR is available

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 4 Sep 2012 17:25:55 +0100

ClientException is meant to represent client-specific exceptions,
MessageProcessingException - exceptions caused during reading the
response entity.

I'd like to note that IMHO the way exceptions can be managed in 2.0
looks very good, but a bit of clarification/update might be needed.

The question is what to expect in the case such as:

target.request("text/xml").get(Book.class); where no MBR is actually
available on the client side. I think it should be:

try {

  target.request("text/xml").get(Book.class);

} catch (ClientException ex) {

   assertTrue(ex.getCause() instanceof MessageProcessingException);

}

Do you all agree with the above ?

Assuming yes, I'd also like to suggest adding one more constructor to
ClientException, the one accepting Response - this might in principle
allow for read retries when no MBR is available, example:

try {

  target.request("text/xml").get(Book.class);

} catch (ClientException ex) {

   Response r = ex.getResponse();
   LOG.info("String content: " + r.readEntity(String.class));

}

Cheers, Sergey