Always return null on attempt to get non-existent field, even from null

This commit is contained in:
Owen Stephens 2018-05-10 16:37:38 -04:00
parent 1e2c0c0a04
commit 13f2ebe9fc

View File

@ -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;
}
}