users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: ParamConverter and Collections

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Thu, 14 Aug 2014 15:56:05 +0200

Hi Sergey,

For QueryParam Jersey automatically creates a List/Set/SortedSet as required by #5 in the javadoc. We use the ParamConverter in step #4 for non-collection types.

HTH,
Marek

On 13 Aug 2014, at 23:11, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:

> Hi Marek
>
> Can you please be very nice tomorrow :-) and reply to the following:
>
> A CXF user is wondering if CXF is compliant or not with respect to the way it treats collections and ParamConverters.
>
> Consider:
>
> @GET
> public Response get(@QueryParam("a") MyAClass a);
>
> ParamConverterProvider.getConverter(MyAClass.class, MyAClass.class, annotations);
>
> would return the converter.
>
> Now, next we have
>
> @GET
> public Response get(@QueryParam("a") List<MyAClass> a);
>
> The user expects that ParamConverterProvider is asked to return a converter for List<MyAClass>.
>
> I said no, there was an agreement that the runtime was dealing with managing the actual Lists or Sets, and ParamConverterProvider would only be asked to provide a converter for MyAClass.
>
> My other argument was that if the runtime were to ask to provide the list/set converters then, given a query like "?a=2&a=4", the runtime would have to pass the actual "a=2&a=4" String to the converter (possibly re-created by the runtime in case the original query is more involved, with multiple 'a' being mixed with other parameters) for it to parse it in order to convert to List/Set. This appears to be fundamentally wrong to me: this would mean that the same converter would also have to be prepared to parse "a=2;a=4" to support Matrix parameter lists. No idea how would one get the converters to convert a list of headers to List/Set, what the runtime would pass to converter.fromString() in case of multiple headers ?
>
> To summarize, I think it is the job of the runtime to take care of managing the actual lists/sets holding multiple parameters.
>
> Does it Jersey do it differently ? Bill, what about RestEasy ?
>
> Thanks, Sergey