This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 484ced85b4103b54c281bb3fb471fa694b56c19c
Author: Andrei Bastun <versh...@users.noreply.github.com>
AuthorDate: Wed Aug 30 16:32:51 2023 +0200

    CXF-8920: use the same approach with Temporal.class.isAssignableFrom check 
as used for non-collection fields to recognize and convert temporal values 
(#1408)
    
    Co-authored-by: Andrei Bastun <andrei.bas...@ist.com>
    (cherry picked from commit f424bda17e26f9db306ecd852228defc5a421986)
---
 .../ext/search/AbstractSearchConditionParser.java      | 10 ++++++++--
 .../cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git 
a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
 
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
index 08c4abaeb7..ca531c9818 100644
--- 
a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
+++ 
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
@@ -194,6 +194,7 @@ public abstract class AbstractSearchConditionParser<T> 
implements SearchConditio
                 && (isPrimitive
                     ||
                     Date.class.isAssignableFrom(returnType)
+                    || Temporal.class.isAssignableFrom(returnType)
                     || returnCollection
                     || paramConverterAvailable(returnType));
 
@@ -207,8 +208,13 @@ public abstract class AbstractSearchConditionParser<T> 
implements SearchConditio
 
             if (lastTry) {
                 if (!returnCollection) {
-                    nextObject = isPrimitive ? 
InjectionUtils.convertStringToPrimitive(value, returnType)
-                        : convertToDate(returnType, value);
+                    if (isPrimitive) {
+                        nextObject = 
InjectionUtils.convertStringToPrimitive(value, returnType);
+                    } else if (Temporal.class.isAssignableFrom(returnType)) {
+                        nextObject = convertToTemporal((Class<? extends 
Temporal>)returnType, value);
+                    } else {
+                        nextObject = convertToDate(returnType, value);
+                    }
                 } else {
                     CollectionCheck collCheck = 
getCollectionCheck(originalPropName, true, actualReturnType);
                     if (collCheck == null) {
diff --git 
a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
 
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
index 26ccf89975..0acf211d5d 100644
--- 
a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
+++ 
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlCollectionsTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxrs.ext.search.fiql;
 
+import java.time.LocalDate;
 import java.util.Set;
 
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
@@ -46,6 +47,14 @@ public class FiqlCollectionsTest {
         assertNotNull(room);
     }
 
+    @Test
+    public void testTemporalUsedOnCollection() throws SearchParseException {
+        FiqlParser<Room> roomParser = new FiqlParser<>(Room.class);
+        SearchCondition<Room> roomCondition = 
roomParser.parse("furniture.spec.features.localDate==2023-08-24");
+        Room room = roomCondition.getCondition();
+        assertNotNull(room);
+    }
+
     public static class Room {
         Set<Furniture> furniture;
         public Set<Furniture> getFurniture() {
@@ -88,11 +97,20 @@ public class FiqlCollectionsTest {
 
     public static class Feature {
         String description;
+        LocalDate localDate;
         public String getDescription() {
             return description;
         }
         public void setDescription(String description) {
             this.description = description;
         }
+
+        public LocalDate getLocalDate() {
+            return localDate;
+        }
+
+        public void setLocalDate(LocalDate localDate) {
+            this.localDate = localDate;
+        }
     }
 }
\ No newline at end of file

Reply via email to