users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Should UriInfo report missing parameters with default values ?

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Thu, 11 Apr 2013 13:57:25 -0400

On Apr 11, 2013, at 9:18 AM, Bill Burke <bburke_at_redhat.com> wrote:

> No, it should not report default values. UriInfo should match and map to the incoming request so you know exactly what the incoming request is. @DefaultValue is a product of injection.

 I agree. @DefaultValue is really a "qualifier" for @*Param.

-- Santiago

>
> On 4/11/2013 5:56 AM, Sergey Beryozkin wrote:
>> Hi
>>
>> Consider
>>
>> GET /somepath
>>
>> @GET
>> public Response get(@QueryParam("a") @DefaultValue("1") String a) {}
>>
>> public class ContainerResponseFilterImpl implements
>> ContainerResponseFilter {
>> @Context UriInfo ui;
>>
>> String a = ui.getQueryParameters().getFirst("a");
>> assertEquals("1", a);
>>
>> }
>>
>> Does it make sense ? It appears to me that, assuming
>>
>> get(@QueryParam("a") @DefaultValue("1") String a)
>>
>> has been invoked, the filter implementation should see the value of the
>> 'a' parameter exactly the way the application code sees it.
>>
>> FYI, a user wanted to see the query parameters in the response filter
>> context and it took a lot of time to figure out why the injected UriInfo
>> was not providing the expected query parameters.
>>
>> If you agree then I'll open a 2.1 JIRA to get UriInfo docs tweaked a
>> bit. Actually, same would apply to HttpHeaders injected into the
>> outbound filters (as well as to ContainerRequestContext available to the
>> outbound filters)
>>
>> Thanks, Sergey
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com