Description
The reference javadoc for @DefaultValue states:
If this annotation is not used and the corresponding metadata is not present in the request, the value will be an empty collection for List, Set or SortedSet, null for other object types, and the Java-defined default for primitive types.
If @QueryParameter is used with a primitive type, a null pointer exeption is thrown rather than setting the parameter to the java-defined default:
@Path("/update/
")
@GET
public Result getUpdates(@PathParam("since") long since, @QueryParam("terse") boolean terse)
org.apache.cxf.interceptor.Fault: null while invoking public com.example.Result com.example.Service.getUpdates(long,boolean) with params [0, null].
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:121)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:113)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:98)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:53)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
$ curl http://localhost:2259/example/update/0
<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.IllegalArgumentException</ns1:faultstring></ns1:XMLFault>
It seems to ignore @DefaultValue altogether, as the same fault happens if the method is changed to:
public Result getUpdates(@PathParam("since") long since, @QueryParam("terse") @DefaultValue("false") boolean terse) { ... }