Always return null on attempt to get non-existent field, even from null
This commit is contained in:
parent
1e2c0c0a04
commit
13f2ebe9fc
@ -63,17 +63,17 @@ public class FieldAccessorExpr implements Evaluable {
|
||||
if (ExpressionUtils.isError(o)) {
|
||||
return o; // bubble the error up
|
||||
} else if (o == null) {
|
||||
return new EvalError("Cannot retrieve field from null");
|
||||
return null;
|
||||
} else if (o instanceof HasFields) {
|
||||
return ((HasFields) o).getField(_fieldName, bindings);
|
||||
} else if (o instanceof JSONObject) {
|
||||
try {
|
||||
return ((JSONObject) o).get(_fieldName);
|
||||
} catch (JSONException e) {
|
||||
return new EvalError("Object does not have any field, including " + _fieldName);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return new EvalError("Object does not have any field, including " + _fieldName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user