You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Matt Inger (JIRA)" <ji...@apache.org> on 2010/04/27 20:16:37 UTC

[jira] Created: (CXF-2787) CXF Extension bit @QueryParam("") does not allow null values in the bean

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.


[jira] Resolved: (CXF-2787) CXF Extension bit @QueryParam("") does not allow null values in the bean

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-2787.
-----------------------------------

         Assignee: Sergey Beryozkin
    Fix Version/s: 2.3
                   2.2.8
       Resolution: Fixed

> 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
>            Assignee: Sergey Beryozkin
>             Fix For: 2.3, 2.2.8
>
>
> 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.