Program: 117266
Project: 117266
Buggy source:
@Override public void onRecordAfterRead(ODocument iDocument){
  super.onRecordAfterRead(iDocument);
  OClass oClass=iDocument.getSchemaClass();
  if (oClass != null) {
    List<String> calcProperties=getCalcProperties(iDocument);
    if (calcProperties != null && calcProperties.size() > 0) {
      for (      String calcProperty : calcProperties) {
        final OProperty property=oClass.getProperty(calcProperty);
        String script=CustomAttribute.CALC_SCRIPT.getValue(property);
        if (!Strings.isEmpty(script)) {
          try {
            List<ODocument> calculated;
            if (FULL_QUERY_PATTERN.matcher(script).find()) {
              calculated=iDocument.getDatabase().query(new OSQLSynchQuery<Object>(script),iDocument);
            }
 else {
              script="String_Node_Str" + script + "String_Node_Str"+ iDocument.getIdentity();
              calculated=iDocument.getDatabase().query(new OSQLSynchQuery<Object>(script));
            }
            if (calculated != null && calculated.size() > 0) {
              OType type=property.getType();
              Object value;
              if (type.isMultiValue()) {
                final OType linkedType=property.getLinkedType();
                value=linkedType == null ? calculated : Lists.transform(calculated,new Function<ODocument,Object>(){
                  @Override public Object apply(                  ODocument input){
                    return OType.convert(input.field("String_Node_Str"),linkedType.getDefaultJavaType());
                  }
                }
);
              }
 else {
                value=calculated.get(0).field("String_Node_Str");
              }
              value=OType.convert(value,type.getDefaultJavaType());
              iDocument.field(calcProperty,value);
            }
          }
 catch (          OCommandSQLParsingException e) {
            LOG.warn("String_Node_Str",e);
            iDocument.field(calcProperty,e.getLocalizedMessage());
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onRecordAfterRead(ODocument iDocument){
  super.onRecordAfterRead(iDocument);
  OClass oClass=iDocument.getSchemaClass();
  if (oClass != null) {
    List<String> calcProperties=getCalcProperties(iDocument);
    if (calcProperties != null && calcProperties.size() > 0) {
      for (      String calcProperty : calcProperties) {
        final OProperty property=oClass.getProperty(calcProperty);
        String script=CustomAttribute.CALC_SCRIPT.getValue(property);
        if (!Strings.isEmpty(script)) {
          try {
            List<ODocument> calculated;
            if (FULL_QUERY_PATTERN.matcher(script).find()) {
              calculated=iDocument.getDatabase().query(new OSQLSynchQuery<Object>(script),iDocument);
            }
 else {
              script="String_Node_Str" + script + "String_Node_Str"+ iDocument.getIdentity();
              calculated=iDocument.getDatabase().query(new OSQLSynchQuery<Object>(script));
            }
            if (calculated != null && calculated.size() > 0) {
              OType type=property.getType();
              Object value;
              if (type.isMultiValue()) {
                final OType linkedType=property.getLinkedType();
                value=linkedType == null ? calculated : Lists.transform(calculated,new Function<ODocument,Object>(){
                  @Override public Object apply(                  ODocument input){
                    return OType.convert(input.field("String_Node_Str"),linkedType.getDefaultJavaType());
                  }
                }
);
              }
 else {
                value=calculated.get(0).field("String_Node_Str");
              }
              value=OType.convert(value,type.getDefaultJavaType());
              Object oldValue=iDocument.field(calcProperty);
              if (oldValue != value && (oldValue == null || !oldValue.equals(value))) {
                iDocument.field(calcProperty,value);
              }
            }
          }
 catch (          OCommandSQLParsingException e) {
            LOG.warn("String_Node_Str",e);
            iDocument.field(calcProperty,e.getLocalizedMessage());
          }
        }
      }
    }
  }
}