users@jax-rs-spec.java.net

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

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 11 Apr 2013 10:56:42 +0100

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