Skip to main content

[jsr339-experts] Re: WebApplicationException Response entity and exception mappers

  • From: Sergey Beryozkin <sberyozkin@...>
  • To: <jsr339-experts@...>
  • Subject: [jsr339-experts] Re: WebApplicationException Response entity and exception mappers
  • Date: Wed, 14 Nov 2012 10:01:51 +0000

On 13/11/12 19:31, Bill Burke wrote:
Resteasy you can write an ExceptionMapper for any exception.

Yes, sure, I was just re-reading

http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-280003.3.4

(thanks to the user pointing me to it) and apparently the first part of that section specifically mentions that WAE with non-empty Response entities are basically not to be submitted to WAE exception mappers:

"If the response property of the exception does not contain an entity and an exception mapping provider (see section 4.4) is available for WebApplicationException an implementation MUST use the provider to create a new Response instance, *otherwise the response property is used directly*"

I hope I'm just misreading it.

We've just had another user reporting a temp regression with WAE mapper not able to see an original cause exception, example:

try {
 doIt();
} catch (BusinessException ex) {
   throw new WebApplicationException(ex);
}

where a custom WAE mapper is expected to check the cause of the current WAE and do something with it.

If the above recommendation was indeed about skipping exception mappers for WAE with non-empty response entities, then all WAE (and subclass) exception constructors like

"WebApplicationException(Response, Throwable)"

would create WAE instances which would miss custom WAE mappers expecting to do something with WAE cause exceptions whenever Response entity is not empty. And I'd consider it a specification bug.

I'd suggest to clarify the listed text, by dropping any references to WAE and possibly recommend that custom mappers should be aware that the caught exception's Response entity may not be null though it is up to them whether to preserve it or not.

Cheers, Sergey



On 11/13/2012 12:25 PM, Sergey Beryozkin wrote:
Hi,

CXF user has pointed out that the specification requires that WAE
exception mapper is not to be used to map a given WAE to Response if
WAE Response entity is not null.

Is it what Jersey and RestEasy do ? CXF lets custom WAE mappers manage
all WAEs, though of course the custom mapper may choose to somehow
modify the original WAE Response entity if any.

I'd rather prefer the mappers see all WAEe (and say NotFoundException
mappers see all the NFE exceptions, whether or not NFE Response entity
is null), example, to make sure all WAE isntances can be given some
common treatment like logging them, etc.

Sergey




[jsr339-experts] WebApplicationException Response entity and exception mappers

Sergey Beryozkin 11/13/2012

[jsr339-experts] Re: WebApplicationException Response entity and exception mappers

Bill Burke 11/13/2012

[jsr339-experts] Re: WebApplicationException Response entity and exception mappers

Sergey Beryozkin 11/14/2012

[jsr339-experts] Re: [jax-rs-spec users] WebApplicationException Response entity and exception mappers

Santiago Pericas-Geertsen 11/16/2012

[jsr339-experts] Re: [jax-rs-spec users] WebApplicationException Response entity and exception mappers

Sergey Beryozkin 11/16/2012

[jsr339-experts] Re: [jax-rs-spec users] WebApplicationException Response entity and exception mappers

Sergey Beryozkin 11/20/2012

[jsr339-experts] Re: [jax-rs-spec users] WebApplicationException Response entity and exception mappers

Bill Burke 11/20/2012

[jsr339-experts] Re: [jax-rs-spec users] WebApplicationException Response entity and exception mappers

Sergey Beryozkin 11/23/2012

[jsr339-experts] Re: [jax-rs-spec users] Re: WebApplicationException Response entity and exception mappers

Santiago Pericas-Geertsen 11/26/2012

[jsr339-experts] Re: [jax-rs-spec users] Re: WebApplicationException Response entity and exception mappers

Sergey Beryozkin 11/27/2012
 
 
Close
loading
Please Confirm
Close