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)) {
|
if (ExpressionUtils.isError(o)) {
|
||||||
return o; // bubble the error up
|
return o; // bubble the error up
|
||||||
} else if (o == null) {
|
} else if (o == null) {
|
||||||
return new EvalError("Cannot retrieve field from null");
|
return null;
|
||||||
} else if (o instanceof HasFields) {
|
} else if (o instanceof HasFields) {
|
||||||
return ((HasFields) o).getField(_fieldName, bindings);
|
return ((HasFields) o).getField(_fieldName, bindings);
|
||||||
} else if (o instanceof JSONObject) {
|
} else if (o instanceof JSONObject) {
|
||||||
try {
|
try {
|
||||||
return ((JSONObject) o).get(_fieldName);
|
return ((JSONObject) o).get(_fieldName);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
return new EvalError("Object does not have any field, including " + _fieldName);
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new EvalError("Object does not have any field, including " + _fieldName);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user