CXF Extension bit @QueryParam("") does not allow null values in the bean
------------------------------------------------------------------------
Key: CXF-2787
URL: https://issues.apache.org/jira/browse/CXF-2787
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 2.2.5
Reporter: Matt Inger
If you use the @QueryParam("") extension bit on a method parameter:
{code}
public void foo(@QueryParam("") Bar bar);
{code}
you cannot have fields in the Bar class with null values. The problem stems
from this method:
{code}
org.apache.cxf.jaxrs.utils.InjectionUtils.fillInValuesFromBean(Object, String,
MultivaluedMap<String, Object>)
{code}
specifically, this piece of code, which assumes the value is not null, and thus
causes a NullPointerException if it is null:
{code}
Object value = extractFromMethod(bean, m);
if (isPrimitive(value.getClass())) {
values.putSingle(propertyName, value);
} else if (isSupportedCollectionOrArray(value.getClass())) {
// ignoring arrrays for a moment
List<Object> theValues = null;
if (value.getClass().isArray()) {
theValues = Arrays.asList(value);
} else {
theValues = CastUtils.cast((List<?>)value);
}
values.put(propertyName, theValues);
} else {
fillInValuesFromBean(value, propertyName, values);
}
{code}
Ideally, if a value is null, one should just ignore the property and not add it
to the parameter map.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.