You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Achraf BELKAHLA (Jira)" <ji...@apache.org> on 2022/02/17 10:05:00 UTC
[jira] [Created] (CXF-8659) Can't filter when attribute type is LocalDate or LocalDateTime
Achraf BELKAHLA created CXF-8659:
------------------------------------
Summary: 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
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)