Source:
<code>public SetExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, SetExpression expr) { this.factory = factory; op = expr.getOp(); for (FieldAndRValue fld : expr.getFields()) { Path field = fld.getField(); LOGGER.debug("Parsing setter for {}", field); RValueExpression rvalue = fld.getRValue(); Path refPath = null; FieldTreeNode refMdNode = null; FieldData data = null; if (rvalue.getType() == RValueExpression.RValueType._dereference) { refPath = rvalue.getPath(); refMdNode = context.resolve(refPath); if (refMdNode == null) { throw new EvaluationError(CrudConstants.ERR_CANT_ACCESS + refPath); } LOGGER.debug("Refpath {}", refPath); } FieldTreeNode mdNode = context.resolve(field); if (mdNode == null) { throw new EvaluationError(CrudConstants.ERR_CANT_ACCESS + field); } if (mdNode instanceof SimpleField || mdNode instanceof SimpleArrayElement) { data = initializeSimple(rvalue, refMdNode, mdNode, field, refPath); } else if (mdNode instanceof ObjectField || mdNode instanceof ObjectArrayElement) { data = initializeObject(rvalue, refMdNode, mdNode, field, refPath); } else if (mdNode instanceof ArrayField) { data = initializeArray(rvalue, refMdNode, mdNode, field, refPath); } <START> if (data != null) { <END> setValues.add(data); } } }</code><technical_language>this work, add if statement *before* instanceof ArrayField (becayse ResolvedReferenceField extends ArrayField) if(mdNode instanceof ResolvedReferenceField) { // then, if set-to is null, set data null, added setValues. If is non-null, throw error, call is setting a reference a non-null value. }</technical_language>

Target:
public SetExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, SetExpression expr) { this.factory = factory; op = expr.getOp(); for (FieldAndRValue fld : expr.getFields()) { Path field = fld.getField(); LOGGER.debug("Parsing setter for {}", field); RValueExpression rvalue = fld.getRValue(); Path refPath = null; FieldTreeNode refMdNode = null; FieldData data = null; if (rvalue.getType() == RValueExpression.RValueType._dereference) { refPath = rvalue.getPath(); refMdNode = context.resolve(refPath); if (refMdNode == null) { throw new EvaluationError(CrudConstants.ERR_CANT_ACCESS + refPath); } LOGGER.debug("Refpath {}", refPath); } FieldTreeNode mdNode = context.resolve(field); if (mdNode == null) { throw new EvaluationError(CrudConstants.ERR_CANT_ACCESS + field); } if (mdNode instanceof SimpleField || mdNode instanceof SimpleArrayElement) { data = initializeSimple(rvalue, refMdNode, mdNode, field, refPath); setValues.add(data); } else if (mdNode instanceof ReferenceField) { if (rvalue.getValue() != null) { throw new EvaluationError(CrudConstants.ERR_ASSIGNMENT + field +" can't assign values to referenced fields"); } else { } } else if (mdNode instanceof ObjectField || mdNode instanceof ObjectArrayElement) { data = initializeObject(rvalue, refMdNode, mdNode, field, refPath); setValues.add(data); } else if (mdNode instanceof ArrayField) { data = initializeArray(rvalue, refMdNode, mdNode, field, refPath); setValues.add(data); } else { throw new EvaluationError(CrudConstants.ERR_ASSIGNMENT + field + " field type "+mdNode.getClass()+" is not recognized!"); } } }