users@jax-rs-spec.java.net

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

From: Bill Burke <bburke_at_redhat.com>
Date: Thu, 11 Apr 2013 09:18:57 -0400

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.

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