Author: lektran
Date: Tue Oct 6 14:07:04 2009
New Revision: 822276
URL:
http://svn.apache.org/viewvc?rev=822276&view=revLog:
Fix an inconsistency in GenericEntity's get methods when the key doesn't exist, get(String) throws an exception but get(Object) just logs a warning. Changed so that both methods just log a warning.
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=822276&r1=822275&r2=822276&view=diff==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Tue Oct 6 14:07:04 2009
@@ -309,7 +309,8 @@
public Object get(String name) {
if (getModelEntity().getField(name) == null) {
- throw new IllegalArgumentException("[GenericEntity.get] \"" + name + "\" is not a field of " + entityName);
+ 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;
}
return fields.get(name);
}
@@ -1343,16 +1344,7 @@
}
public Object get(Object key) {
- try {
- return this.get((String) key);
- } catch (IllegalArgumentException e) {
- if (Debug.verboseOn()) {
- Debug.logVerbose(e, "The field name (or key) [" + key + "] 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) [" + key + "] 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;
- }
+ return this.get((String) key);
}
public java.util.Set<String> keySet() {