users@jersey.java.net

Re: [Jersey] Why do IllegalArgumentExceptions cause a 404 instead of a 400?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Sat, 15 Aug 2009 10:29:04 +0200

On Aug 14, 2009, at 10:00 PM, DirkM wrote:

>
>
> Paul Sandoz wrote:
>>
>> The EG opted for a 404 when extracting parameters from URI because
>> strictly speaking if a String cannot be converted to say Integer then
>> it is a matching error with the URI.
>>
>
> Thanks for the quick response Paul.
>
> I guess you could look at it that way, but it seems quite
> unintuitive to me
> as a web developer, as opposed to someone initiated with the details
> of the
> JAX-RS standard.
>
> The http://www.ietf.org/rfc/rfc2616.txt HTTP standard states:
> 10.4.1 400 Bad Request
>
> The request could not be understood by the server due to malformed
> syntax. The client SHOULD NOT repeat the request without
> modifications.
>

Yes. Originally we returned a 400 for all parameters then we changed
it for Path, Matrix and Query parameters. But I can see the latter
going either way.

I do not think you can rely on IllegalArgumentException as the cause
in WebApplcationException in all cases. I think the ExceptionMapper is
an appropriate location to modify the default behavior but what we
require is something like a ParameterProcessingException that extends
WebApplcationException. The ParameterProcessingException would contain
the type of the parameter, then you can map this exception.

Could you log an issue. I will work on it.

Thanks,
Paul.

>
> --
> View this message in context: http://n2.nabble.com/Why-do-IllegalArgumentExceptions-cause-a-404-instead-of-a-400--tp3447019p3447207.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>