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

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 304b134b1df2bcabf72c0d20c739c38fa5a54301
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Wed Apr 2 14:52:35 2025 +0200

    Fix a `ClassCastException` in the comparison of temporal objects.
---
 .../main/org/apache/sis/filter/TemporalFilter.java                  | 6 +++---
 .../main/org/apache/sis/temporal/TimeMethods.java                   | 2 +-
 incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
index 8619c71015..6413abcadc 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
@@ -201,7 +201,7 @@ class TemporalFilter<R,T> extends BinaryFunction<R,T,T>
                 }
             } catch (DateTimeException e) {
                 throw new InvalidFilterValueException(Errors.format(
-                        Errors.Keys.CannotCompareInstanceOf_2, 
left.getClass(), right.getClass()));
+                        Errors.Keys.CannotCompareInstanceOf_2, 
left.getClass(), right.getClass()), e);
             }
         }
         return false;
@@ -240,7 +240,7 @@ class TemporalFilter<R,T> extends BinaryFunction<R,T,T>
                     return operation.evaluate(left, right);
                 } catch (DateTimeException e) {
                     throw new InvalidFilterValueException(Errors.format(
-                            Errors.Keys.CannotCompareInstanceOf_2, 
left.getClass(), right.getClass()));
+                            Errors.Keys.CannotCompareInstanceOf_2, 
left.getClass(), right.getClass()), e);
                 }
             }
             return false;
@@ -280,7 +280,7 @@ class TemporalFilter<R,T> extends BinaryFunction<R,T,T>
                     return operation.evaluate(left, right);
                 } catch (DateTimeException e) {
                     throw new InvalidFilterValueException(Errors.format(
-                            Errors.Keys.CannotCompareInstanceOf_2, 
left.getClass(), right.getClass()));
+                            Errors.Keys.CannotCompareInstanceOf_2, 
left.getClass(), right.getClass()), e);
                 }
             }
             return false;
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TimeMethods.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TimeMethods.java
index da063eeb9e..5cc49c0f66 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TimeMethods.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/TimeMethods.java
@@ -219,7 +219,7 @@ public class TimeMethods<T> implements Serializable {
                 }
                 return p.test(self, other);
             }
-        } else if (self instanceof Comparable<?> && type.isInstance(other)) {
+        } else if (self instanceof Comparable<?> && 
self.getClass().isInstance(other)) {
             /*
              * The type of the first operand is not a special case, but the 
second operand is compatible
              * for a call to the generic `compareTo(…)` method. This case does 
not happen often, because
diff --git a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java 
b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java
index d6096d76cf..472228bb9a 100644
--- a/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java
+++ b/incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java
@@ -284,7 +284,7 @@ public final class CQL {
                 case INT:   return ff.literal(Integer.valueOf(tree.getText()));
                 case FLOAT: return ff.literal(Double.valueOf(tree.getText()));
                 case DATE: {
-                    TemporalAccessor ta = 
LenientDateFormat.FORMAT.parse(tree.getText());
+                    TemporalAccessor ta = 
LenientDateFormat.parseBest(tree.getText());
                     return ff.literal(ta);
                     // TODO: return 
ff.literal(TemporalObjects.getTimeInMillis(tree.getText()));
                 }

Reply via email to