You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/05/20 22:27:23 UTC

svn commit: r1340826 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java

Author: jleroux
Date: Sun May 20 20:27:23 2012
New Revision: 1340826

URL: http://svn.apache.org/viewvc?rev=1340826&view=rev
Log:
A patch from Daniel Riquelme "ignore-if-empty in entity-options throw NPE when env-name is in fact empty" https://issues.apache.org/jira/browse/OFBIZ-4843

When specifying the ignore-if-empty attribute inside an entity-constraint in an entity-options a NPE will be thrown whenever the env-name of this entity-constraint is empty.

The error occurs because a null condition is created for the entity-constraint.
When validateSql get called in

org.ofbiz.entity.condition.EntityJoinOperator.validateSql(EntityJoinOperator.java:178)

there is no null checking so when

condition.checkCondition(modelEntity);

gets called an NPE is thrown.

The patch modifies the code in

framework/widget/src/org/ofbiz/widget/form/ModelFormField.java

to avoid the inclusion of a null condition to the entity-options.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=1340826&r1=1340825&r2=1340826&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Sun May 20 20:27:23 2012
@@ -1587,7 +1587,10 @@ public class ModelFormField {
                     if (modelEntity == null) {
                         throw new IllegalArgumentException("Error in entity-options: could not find entity [" + this.entityName + "]");
                     }
-                    expandedConditionList.add(condition.createCondition(context, modelEntity, delegator.getModelFieldTypeReader(modelEntity)));
+                    EntityCondition createdCondition = condition.createCondition(context, modelEntity, delegator.getModelFieldTypeReader(modelEntity));
+                    if (createdCondition!=null) {
+                        expandedConditionList.add(createdCondition);
+                    }
                 }
                 findCondition = EntityCondition.makeCondition(expandedConditionList);
             }