You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (Jira)" <ji...@apache.org> on 2022/02/19 00:35:00 UTC
[jira] [Updated] (CXF-8659) Can't filter when attribute type is LocalDate or LocalDateTime
[ https://issues.apache.org/jira/browse/CXF-8659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andriy Redko updated CXF-8659:
------------------------------
Labels: 3.4.6 3.5.1 (was: )
> Can't filter when attribute type is LocalDate or LocalDateTime
> --------------------------------------------------------------
>
> Key: CXF-8659
> URL: https://issues.apache.org/jira/browse/CXF-8659
> Project: CXF
> Issue Type: Improvement
> Components: JAX-RS
> Reporter: Achraf BELKAHLA
> Priority: Blocker
> Labels: 3.4.6, 3.5.1
>
> When trying to filter using fiql language :
> filter:"closingDate=gt=2014-11-04"
> with *closingDate* is of type *LocalDate.*
> We get the exception *"Cannot convert String Value to a value of class LocalDate"*
>
> *Cause :* in AbstractSearchConditionParser:: ParseType :
> {code:java}
> if (Date.class.isAssignableFrom(valueType)) {
> castedValue = convertToDate(valueType, value);
> } else {
> boolean isPrimitive = InjectionUtils.isPrimitive(valueType);
> boolean isPrimitiveOrEnum = isPrimitive || valueType.isEnum();
> if (ownerBean == null || isPrimitiveOrEnum) {
> try {
> CollectionCheck collCheck = getCollectionCheck(originalPropName, isCollection, actualType);
> if (collCheck == null) {
> castedValue = InjectionUtils.convertStringToPrimitive(value, actualType);
> }
> if (collCheck == null && isCollection) {
> castedValue = getCollectionSingleton(valueType, castedValue);
> } else if (isCollection) {
> typeInfo.setCollectionCheckInfo(new CollectionCheckInfo(collCheck, castedValue));
> castedValue = getEmptyCollection(valueType);
> }
> } catch (Exception e) {
> throw new SearchParseException("Cannot convert String value \"" + value
> + "\" to a value of class " + valueType.getName(), e);
> }
> } else {
> Class<?> classType = isCollection ? valueType : value.getClass();
> try {
> Method setterM = valueType.getMethod("set" + getMethodNameSuffix(setter),
> new Class[]{classType});
> Object objectValue = !isCollection ? value : getCollectionSingleton(valueType, value);
> setterM.invoke(ownerBean, new Object[]{objectValue});
> castedValue = objectValue;
> } catch (Throwable ex) {
> throw new SearchParseException("Cannot convert String value \"" + value
> + "\" to a value of class " + valueType.getName(), ex);
> } }
> } {code}
> {*}{*}-> here the code consider LocalDate as a primitive Type and tries to cast it.
> -> Can we consider adding LocalDate and LocalDateTime types like doing with the Date type ?
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)