users@jersey.java.net

[Jersey] Re: Response.getStatus() and code readability

From: Julian Reschke <julian.reschke_at_gmx.de>
Date: Tue, 12 Nov 2013 15:37:09 +0100

On 2013-11-12 13:44, Marek Potociar wrote:
>
> On 08 Nov 2013, at 21:44, cowwoc <cowwoc_at_bbs.darktech.org
> <mailto:cowwoc_at_bbs.darktech.org>> wrote:
>
>> Hi,
>>
>> I noticed Jersey 2.0 moved from returning an enum Status to returning
>> an int code.
>
> Jerse 2.0 uses JAX-RS API. JAX-RS Response.getStatus() always returned
> int, there was no way to change it.
>
>> Can you please explain the reasoning and suggest a way to use switch()
>> statements on response codes while keeping things readable?
>
> Here are the reasons:
>
> 1. See above - existing JAX-RS Response API
> 2. We have received several bug reports in Jersey 1.x that it is not
> possible to support custom reason phrase. This is indeed impossible with
> enum.
> ...

I assume you mean "custom status codes"?

Anyway: the answer is that HTTP status codes are extensible, so making
this an enum is a bug.

Best regards, Julian