svn commit: r1646666 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1646666 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java

jacopoc
Author: jacopoc
Date: Fri Dec 19 10:54:13 2014
New Revision: 1646666

URL: http://svn.apache.org/r1646666
Log:
OFBIZ-5004: an IllegalArgumentException is thrown if an attempt to select an invalid field is performed; the code was just logging a warning message. Thanks to Christoph Neuroth, Adrian Crum, Paul Foxworthy, Scott Gray, Jacques Le Roux, Adam Heath for their valuable feedback and comments.


Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=1646666&r1=1646665&r2=1646666&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Fri Dec 19 10:54:13 2014
@@ -370,8 +370,7 @@ public class GenericEntity implements Ma
 
     public Object get(String name) {
         if (getModelEntity().getField(name) == null) {
-            Debug.logWarning("The field name (or key) [" + name + "] is not valid for entity [" + this.getEntityName() + "], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception.", module);
-            return null;
+            throw new IllegalArgumentException("The field name (or key) [" + name + "] is not valid for entity [" + this.getEntityName() + "].");
         }
         return fields.get(name);
     }
@@ -784,18 +783,7 @@ public class GenericEntity implements Ma
      *    property value is returned; otherwise returns the field value
      */
     public Object get(String name, String resource, Locale locale) {
-        Object fieldValue = null;
-        try {
-            fieldValue = get(name);
-        } catch (IllegalArgumentException e) {
-            if (Debug.verboseOn()) {
-                Debug.logVerbose(e, "The field name (or key) [" + name + "] is not valid for entity [" + this.getEntityName() + "], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception.", module);
-            } else {
-                Debug.logWarning("The field name (or key) [" + name + "] is not valid for entity [" + this.getEntityName() + "], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception.", module);
-            }
-            return null;
-        }
-
+        Object fieldValue = get(name);
         // In case of view entity first try to retrieve with View field names
         ModelEntity modelEntityToUse = this.getModelEntity();
         Object resourceValue = get(this.getModelEntity(), modelEntityToUse, name, resource, locale);