You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Anthony Durussel (Jira)" <ji...@apache.org> on 2021/12/07 13:57:00 UTC

[jira] [Created] (CXF-8624) CXF Extension @QueryParam("") does not parse correctly LocalDate in the bean

Anthony Durussel created CXF-8624:
-------------------------------------

             Summary: CXF Extension @QueryParam("") does not parse correctly LocalDate in the bean
                 Key: CXF-8624
                 URL: https://issues.apache.org/jira/browse/CXF-8624
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 3.4.5
            Reporter: Anthony Durussel


If you use the @QueryParam("") extension on a method parameter:
{code:java}
public void foo(@QueryParam("") Bar bar);
{code}
with Bar class equals to :
{code:java}
public class Bar  {
    private LocalDate date;
} {code}
The URL generate from the following method parse the localDate as a standard object instead of singleValue as it's done for standard java.util.date
{code:java}
org.apache.cxf.jaxrs.utils.InjectionUtils.fillInValuesFromBean(Object, String, MultivaluedMap<String, Object>)
{code}
{code:java}
if (isPrimitive(value.getClass()) || Date.class.isAssignableFrom(value.getClass())) {
    values.putSingle(propertyName, value);
} else if (value.getClass().isEnum()) {
    values.putSingle(propertyName, value.toString());
} else if (isSupportedCollectionOrArray(value.getClass())) {
    final List<Object> theValues;
    if (value.getClass().isArray()) {
        theValues = Arrays.asList((Object[])value);
    } else if (value instanceof Set) {
        theValues = new ArrayList<>((Set<?>)value);
    } else {
        theValues = CastUtils.cast((List<?>)value);
    }
    values.put(propertyName, theValues);
} else if (Map.class.isAssignableFrom(value.getClass())) {
    if (isSupportedMap(m.getGenericReturnType())) {
        Map<Object, Object> map = CastUtils.cast((Map<?, ?>)value);
        for (Map.Entry<Object, Object> entry : map.entrySet()) {
            values.add(propertyName + '.' + entry.getKey().toString(),
                    entry.getValue().toString());
        }
    }
} else {
    fillInValuesFromBean(value, propertyName, values);
}{code}
Ideally, we should add the LocalDate in the first "if condition" to handle it correctly



--
This message was sent by Atlassian Jira
(v8.20.1#820001)