@QueryParam is not following reference javadoc for primitive types
------------------------------------------------------------------
Key: CXF-1675
URL: https://issues.apache.org/jira/browse/CXF-1675
Project: CXF
Issue Type: Bug
Components: REST
Affects Versions: 2.1.2
Reporter: Joe Sunday
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/{id}")
@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) { ... }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.