dev@jersey.java.net

Re: Valid paramer types and exception handling

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 14 Jan 2009 17:43:28 +0100

On Jan 14, 2009, at 5:27 PM, Marc Hadley wrote:

> On Jan 14, 2009, at 10:24 AM, Sergey Beryozkin wrote:
>>
>> Section 3.2 says that types which have a constructor that accepts a
>> single String argument or a static method valueOf(String) are
>> supported. Also, the section says that WebApplicationException
>> needs to be thrown if exception occurs during the object
>> construction (using constructor or valueOf)
>>
>> few questions.
>>
>> 1. what should happen if a given parameter type has no valid
>> constructor or valueOf() - should an exception be thrown or a null
>> value returned ?
>>
> That is not currently defined in the spec, its something you could
> pick up during initialization/validation rather than at runtime.
> That said, it seems like a 500 would be most appropriate if
> validation is delayed until runtime.
>
>> 2. Some Java types such as java.util.UUID have no valueOf(String)
>> but have fromString(String) method instead. Would it make sense to
>> have such methods evaluated too ?
>>
> Yes, that would also get round an issue with Enum where you can't
> override the valueOf method. I'll add this to the maintenance
> release unless there are objections ?
>

Need to define precedence if fromString and valueOf are both present,
which if we want to support enum means that fromString takes
precedence over valueOf, which could break backwards compatibility if
there are any, which i doubt there are, existing applications with
classes that have both methods defined.


>> 3. What HTTP status code should be set if an exception occurs
>> during a @FormParam parameter construction - 404 or 400
>>
> I think 400 would be most appropriate. I'll add this to the
> maintenance release unless there are objections ?

No objections.

Paul.

>
>
>> 4. If a field initialization fails due to SecurityManager
>> restrictions then will it also be treated as a client error ?
>
> Seems like a 500 would be most appropriate since the error is due to
> misconfiguration on the server side.
>
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>