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

deepak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new 19d82f640b Fixed:  ClassCastException in 
EntityConditionBuilder.createNode when using EntityFunction keys (OFBIZ-13268) 
Fixed: ClassCastException in EntityConditionBuilder.createNode when using 
EntityFunction keys (OFBIZ-13268) Updated EntityConditionBuilder to handle keys 
like EntityFunction properly, avoiding ClassCastException after the JDK 17 
upgrade.
19d82f640b is described below

commit 19d82f640b556a41b34532f0d282271dce9b64f8
Author: Deepak Dixit <dee...@apache.org>
AuthorDate: Tue Jun 24 10:17:38 2025 +0530

    Fixed:  ClassCastException in EntityConditionBuilder.createNode when using 
EntityFunction keys (OFBIZ-13268)
    Fixed: ClassCastException in EntityConditionBuilder.createNode when
    using EntityFunction keys
    (OFBIZ-13268)
    Updated EntityConditionBuilder to handle keys like EntityFunction
    properly, avoiding ClassCastException after the JDK 17 upgrade.
    
    manually cherry picked from commit 7c098dbd5431c7e079ba227581de0fb1c691aca2
---
 .../ofbiz/entity/condition/EntityConditionBuilder.java    | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java
 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java
index 60b6a5501a..f820bf16d1 100644
--- 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java
+++ 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java
@@ -106,12 +106,21 @@ public class EntityConditionBuilder extends 
BuilderSupport {
 
     @Override
     protected Object createNode(Object methodName, 
@SuppressWarnings("rawtypes") Map mapArg) {
-        Map<String, Object> fieldValueMap = UtilGenerics.cast(mapArg);
+        Map<Object, Object> fieldValueMap = UtilGenerics.cast(mapArg);
         String operatorName = ((String) 
methodName).toLowerCase(Locale.getDefault());
         EntityComparisonOperator<String, Object> operator = 
EntityOperator.lookupComparison(operatorName);
         List<EntityCondition> conditionList = new LinkedList<>();
-        for (Map.Entry<String, Object> entry : fieldValueMap.entrySet()) {
-            conditionList.add(EntityCondition.makeCondition(entry.getKey(), 
operator, entry.getValue()));
+        for (Map.Entry<Object, Object> entry : fieldValueMap.entrySet()) {
+            Object key = entry.getKey();
+            EntityConditionValue lhs;
+            if (key instanceof String) {
+                lhs = EntityFieldValue.makeFieldValue((String) key);
+            } else if (key instanceof EntityConditionValue) {
+                lhs = (EntityConditionValue) key;
+            } else {
+                throw new IllegalArgumentException("Unsupported key type: " + 
key.getClass().getName());
+            }
+            conditionList.add(EntityCondition.makeCondition(lhs, operator, 
entry.getValue()));
         }
         if (conditionList.size() == 1) {
             return new ConditionHolder(conditionList.get(0));

Reply via email to