Program: 104725
Project: 104725
Buggy source:
public Object toMongoObject(MappedField mf,MappedClass mc,Object value){
  Object mappedValue=value;
  if ((mf != null && (mf.hasAnnotation(Reference.class) || mf.getType().isAssignableFrom(Key.class) || mf.getType().isAssignableFrom(DBRef.class)|| (value instanceof Iterable && (mf.getSubClass().isAssignableFrom(Key.class) || mf.getSubClass().isAssignableFrom(DBRef.class))))) || (mc != null && mc.getEntityAnnotation() != null)) {
    try {
      if (value instanceof Iterable) {
        ArrayList<DBRef> refs=new ArrayList<DBRef>();
        Iterable it=(Iterable)value;
        for (        Object o : it) {
          Key<?> k=(o instanceof Key) ? (Key<?>)o : getKey(o);
          DBRef dbref=keyToRef(k);
          refs.add(dbref);
        }
        mappedValue=refs;
      }
 else {
        Key<?> k=(value instanceof Key) ? (Key<?>)value : getKey(value);
        mappedValue=keyToRef(k);
        if (mappedValue == value)         throw new ValidationException("String_Node_Str");
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str" + value + "String_Node_Str",e);
      mappedValue=toMongoObject(value,false);
    }
  }
 else   if (mf != null && mf.hasAnnotation(Serialized.class))   try {
    mappedValue=Serializer.serialize(value,!mf.getAnnotation(Serialized.class).disableCompression());
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
 else   if (value instanceof DBObject)   mappedValue=value;
 else {
    mappedValue=toMongoObject(value,EmbeddedMapper.shouldSaveClassName(value,mappedValue,mf));
    if (mappedValue instanceof DBObject && !EmbeddedMapper.shouldSaveClassName(value,mappedValue,mf))     ((DBObject)mappedValue).removeField(CLASS_NAME_FIELDNAME);
  }
  return mappedValue;
}

Fixed version (ground truth):
public Object toMongoObject(MappedField mf,MappedClass mc,Object value){
  Object mappedValue=value;
  if ((mf != null && (mf.hasAnnotation(Reference.class) || mf.getType().isAssignableFrom(Key.class) || mf.getType().isAssignableFrom(DBRef.class)|| (value instanceof Iterable && mf.isMultipleValues() && (mf.getSubClass().isAssignableFrom(Key.class) || mf.getSubClass().isAssignableFrom(DBRef.class))))) || (mc != null && mc.getEntityAnnotation() != null)) {
    try {
      if (value instanceof Iterable) {
        ArrayList<DBRef> refs=new ArrayList<DBRef>();
        Iterable it=(Iterable)value;
        for (        Object o : it) {
          Key<?> k=(o instanceof Key) ? (Key<?>)o : getKey(o);
          DBRef dbref=keyToRef(k);
          refs.add(dbref);
        }
        mappedValue=refs;
      }
 else {
        Key<?> k=(value instanceof Key) ? (Key<?>)value : getKey(value);
        mappedValue=keyToRef(k);
        if (mappedValue == value)         throw new ValidationException("String_Node_Str");
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str" + value + "String_Node_Str",e);
      mappedValue=toMongoObject(value,false);
    }
  }
 else   if (mf != null && mf.hasAnnotation(Serialized.class))   try {
    mappedValue=Serializer.serialize(value,!mf.getAnnotation(Serialized.class).disableCompression());
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
 else   if (value instanceof DBObject)   mappedValue=value;
 else {
    mappedValue=toMongoObject(value,EmbeddedMapper.shouldSaveClassName(value,mappedValue,mf));
    if (mappedValue instanceof DBObject && !EmbeddedMapper.shouldSaveClassName(value,mappedValue,mf))     ((DBObject)mappedValue).removeField(CLASS_NAME_FIELDNAME);
  }
  return mappedValue;
}