nus-yam/ex-repair huggingface dataset:
Program: 104673
Project: 104673
Buggy source:
public <T>Key<T> merge(final T entity,final WriteConcern wc){
  T unwrapped=entity;
  final LinkedHashMap<Object,DBObject> involvedObjects=new LinkedHashMap<Object,DBObject>();
  final DBObject dbObj=mapper.toDBObject(unwrapped,involvedObjects);
  final Key<T> key=getKey(unwrapped);
  unwrapped=ProxyHelper.unwrap(unwrapped);
  final Object id=getId(unwrapped);
  if (id == null) {
    throw new MappingException("String_Node_Str" + unwrapped.getClass().getName());
  }
  dbObj.removeField(Mapper.ID_KEY);
  WriteResult wr;
  final MappedClass mc=mapper.getMappedClass(unwrapped);
  final DBCollection dbColl=getCollection(unwrapped);
  wr=tryVersionedUpdate(dbColl,unwrapped,dbObj,wc,db,mc);
  if (wr == null) {
    final Query<T> query=(Query<T>)createQuery(unwrapped.getClass()).filter(Mapper.ID_KEY,id);
    wr=update(query,new BasicDBObject("String_Node_Str",dbObj),false,false,wc).getWriteResult();
  }
  final UpdateResults<T> res=new UpdateResults<T>(wr);
  throwOnError(wc,wr);
  final CommandResult gle=wr.getCachedLastError();
  if (gle != null && res.getUpdatedCount() == 0) {
    throw new UpdateException("String_Node_Str" + gle);
  }
  postSaveOperations(unwrapped,dbObj,involvedObjects);
  return key;
}

Fixed version (ground truth):
public <T>Key<T> merge(final T entity,final WriteConcern wc){
  T unwrapped=entity;
  final LinkedHashMap<Object,DBObject> involvedObjects=new LinkedHashMap<Object,DBObject>();
  final DBObject dbObj=mapper.toDBObject(unwrapped,involvedObjects);
  final Key<T> key=getKey(unwrapped);
  unwrapped=ProxyHelper.unwrap(unwrapped);
  final Object id=getId(unwrapped);
  if (id == null) {
    throw new MappingException("String_Node_Str" + unwrapped.getClass().getName());
  }
  final Object idValue=dbObj.get(Mapper.ID_KEY);
  dbObj.removeField(Mapper.ID_KEY);
  WriteResult wr;
  final MappedClass mc=mapper.getMappedClass(unwrapped);
  final DBCollection dbColl=getCollection(unwrapped);
  wr=tryVersionedUpdate(dbColl,unwrapped,dbObj,idValue,wc,db,mc);
  if (wr == null) {
    final Query<T> query=(Query<T>)createQuery(unwrapped.getClass()).filter(Mapper.ID_KEY,id);
    wr=update(query,new BasicDBObject("String_Node_Str",dbObj),false,false,wc).getWriteResult();
  }
  final UpdateResults<T> res=new UpdateResults<T>(wr);
  throwOnError(wc,wr);
  final CommandResult gle=wr.getCachedLastError();
  if (gle != null && res.getUpdatedCount() == 0) {
    throw new UpdateException("String_Node_Str" + gle);
  }
  postSaveOperations(unwrapped,dbObj,involvedObjects);
  return key;
}
Program: 104674
Project: 104674
Buggy source:
protected <T>WriteResult tryVersionedUpdate(final DBCollection dbColl,final T entity,final DBObject dbObj,final WriteConcern wc,final DB database,final MappedClass mc){
  WriteResult wr=null;
  if (mc.getFieldsAnnotatedWith(Version.class).isEmpty()) {
    return wr;
  }
  final MappedField mfVersion=mc.getFieldsAnnotatedWith(Version.class).get(0);
  final String versionKeyName=mfVersion.getNameToStore();
  final Long oldVersion=(Long)mfVersion.getFieldValue(entity);
  final long newVersion=VersionHelper.nextValue(oldVersion);
  dbObj.put(versionKeyName,newVersion);
  if (oldVersion != null && oldVersion > 0) {
    final Object idValue=dbObj.get(Mapper.ID_KEY);
    final UpdateResults<T> res=update(find(dbColl.getName(),(Class<T>)entity.getClass()).filter(Mapper.ID_KEY,idValue).filter(versionKeyName,oldVersion),dbObj,false,false,wc);
    wr=res.getWriteResult();
    if (res.getUpdatedCount() != 1) {
      throw new ConcurrentModificationException("String_Node_Str" + entity.getClass().getName() + "String_Node_Str"+ idValue+ "String_Node_Str"+ oldVersion+ "String_Node_Str");
    }
  }
 else   if (wc == null) {
    wr=dbColl.save(dbObj);
  }
 else {
    wr=dbColl.save(dbObj,wc);
  }
  mfVersion.setFieldValue(entity,newVersion);
  return wr;
}

Fixed version (ground truth):
protected <T>WriteResult tryVersionedUpdate(final DBCollection dbColl,final T entity,final DBObject dbObj,final Object idValue,final WriteConcern wc,final DB database,final MappedClass mc){
  WriteResult wr=null;
  if (mc.getFieldsAnnotatedWith(Version.class).isEmpty()) {
    return wr;
  }
  final MappedField mfVersion=mc.getFieldsAnnotatedWith(Version.class).get(0);
  final String versionKeyName=mfVersion.getNameToStore();
  final Long oldVersion=(Long)mfVersion.getFieldValue(entity);
  final long newVersion=VersionHelper.nextValue(oldVersion);
  dbObj.put(versionKeyName,newVersion);
  if (oldVersion != null && oldVersion > 0) {
    final UpdateResults<T> res=update(find(dbColl.getName(),(Class<T>)entity.getClass()).filter(Mapper.ID_KEY,idValue).filter(versionKeyName,oldVersion),dbObj,false,false,wc);
    wr=res.getWriteResult();
    if (res.getUpdatedCount() != 1) {
      throw new ConcurrentModificationException("String_Node_Str" + entity.getClass().getName() + "String_Node_Str"+ idValue+ "String_Node_Str"+ oldVersion+ "String_Node_Str");
    }
  }
 else   if (wc == null) {
    wr=dbColl.save(dbObj);
  }
 else {
    wr=dbColl.save(dbObj,wc);
  }
  mfVersion.setFieldValue(entity,newVersion);
  return wr;
}
Program: 104675
Project: 104675
Buggy source:
private Class getClass(DBObject dbObj){
  String className=(String)dbObj.get(Mapper.CLASS_NAME_FIELDNAME);
  Class c=null;
  if (className != null) {
    try {
      c=Class.forName(className,true,Thread.currentThread().getContextClassLoader());
    }
 catch (    ClassNotFoundException e) {
      if (log.isWarningEnabled())       log.warning("String_Node_Str",e);
    }
  }
  return c;
}

Fixed version (ground truth):
private Class getClass(DBObject dbObj){
  String className=(String)dbObj.get(Mapper.CLASS_NAME_FIELDNAME);
  Class c=null;
  if (className != null) {
    try {
      c=Class.forName(className,true,getClassLoaderForClass(className,dbObj));
    }
 catch (    ClassNotFoundException e) {
      if (log.isWarningEnabled())       log.warning("String_Node_Str",e);
    }
  }
  return c;
}
Program: 104676
Project: 104676
Buggy source:
private void writeCollection(final MappedField mf,final DBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Iterable coll=null;
  if (mf.isArray)   coll=Arrays.asList((Object[])fieldValue);
 else   coll=(Iterable)fieldValue;
  if (coll != null) {
    List values=new ArrayList();
    for (    Object o : coll) {
      if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(o.getClass()))       values.add(mapr.converters.encode(o));
 else {
        Object val;
        if (Collection.class.isAssignableFrom(o.getClass()) || Map.class.isAssignableFrom(o.getClass()))         val=mapr.toMongoObject(o,true);
 else         val=mapr.toDBObject(o,involvedObjects);
        if (!shouldSaveClassName(o,val,mf))         ((DBObject)val).removeField(Mapper.CLASS_NAME_FIELDNAME);
        values.add(val);
      }
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties) {
      dbObject.put(name,values);
    }
  }
}

Fixed version (ground truth):
private void writeCollection(final MappedField mf,final DBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Iterable coll=null;
  if (fieldValue != null)   if (mf.isArray)   coll=Arrays.asList((Object[])fieldValue);
 else   coll=(Iterable)fieldValue;
  if (coll != null) {
    List values=new ArrayList();
    for (    Object o : coll) {
      if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(o.getClass()))       values.add(mapr.converters.encode(o));
 else {
        Object val;
        if (Collection.class.isAssignableFrom(o.getClass()) || Map.class.isAssignableFrom(o.getClass()))         val=mapr.toMongoObject(o,true);
 else         val=mapr.toDBObject(o,involvedObjects);
        if (!shouldSaveClassName(o,val,mf))         ((DBObject)val).removeField(Mapper.CLASS_NAME_FIELDNAME);
        values.add(val);
      }
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties) {
      dbObject.put(name,values);
    }
  }
}
Program: 104677
Project: 104677
Buggy source:
<T>WriteResult delete(String kind,T id);

Fixed version (ground truth):
<T,V>WriteResult delete(String kind,Class<T> clazz,V id);
Program: 104678
Project: 104678
Buggy source:
private void writeCollection(final MappedField mf,final DBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Iterable coll=null;
  if (fieldValue != null)   if (mf.isArray)   coll=Arrays.asList((Object[])fieldValue);
 else   coll=(Iterable)fieldValue;
  if (coll != null) {
    List values=new ArrayList();
    for (    Object o : coll) {
      if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(o.getClass()))       values.add(mapr.converters.encode(o));
 else {
        Object val;
        if (Collection.class.isAssignableFrom(o.getClass()) || Map.class.isAssignableFrom(o.getClass()))         val=mapr.toMongoObject(o,true);
 else         val=mapr.toDBObject(o,involvedObjects);
        if (!shouldSaveClassName(o,val,mf))         ((DBObject)val).removeField(Mapper.CLASS_NAME_FIELDNAME);
        values.add(val);
      }
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties) {
      dbObject.put(name,values);
    }
  }
}

Fixed version (ground truth):
private void writeCollection(final MappedField mf,final DBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Iterable coll=null;
  if (fieldValue != null)   if (mf.isArray)   coll=Arrays.asList((Object[])fieldValue);
 else   coll=(Iterable)fieldValue;
  if (coll != null) {
    List values=new ArrayList();
    for (    Object o : coll) {
      if (null == o)       values.add(null);
 else       if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(o.getClass()))       values.add(mapr.converters.encode(o));
 else {
        Object val;
        if (Collection.class.isAssignableFrom(o.getClass()) || Map.class.isAssignableFrom(o.getClass()))         val=mapr.toMongoObject(o,true);
 else         val=mapr.toDBObject(o,involvedObjects);
        if (!shouldSaveClassName(o,val,mf))         ((DBObject)val).removeField(Mapper.CLASS_NAME_FIELDNAME);
        values.add(val);
      }
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties) {
      dbObject.put(name,values);
    }
  }
}
Program: 104679
Project: 104679
Buggy source:
@Override public String encode(Object uri,MappedField optionalExtraInfo){
  return ((URI)uri).toString().replace("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override public String encode(Object uri,MappedField optionalExtraInfo){
  if (uri == null)   return null;
  return ((URI)uri).toString().replace("String_Node_Str","String_Node_Str");
}
Program: 104680
Project: 104680
Buggy source:
public List<T> findIds(Query<T> q){
  return (List<T>)keysToIds(q.asKeyList());
}

Fixed version (ground truth):
public List<K> findIds(Query<T> q){
  return (List<K>)keysToIds(q.asKeyList());
}
Program: 104681
Project: 104681
Buggy source:
/** 
 * Finds the entities Ts by the criteria {key:value}
 */
public List<T> findIds(Query<T> q);

Fixed version (ground truth):
/** 
 * Finds the entities Ts by the criteria {key:value}
 */
public List<K> findIds(Query<T> q);
Program: 104682
Project: 104682
Buggy source:
@SuppressWarnings("String_Node_Str") <T>MapreduceResults<T> mapReduce(MapreduceType type,Query q,String map,String reduce,String finalize,Map<String,Object> scopeFields,Class<T> outputType);

Fixed version (ground truth):
/** 
 * Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher
 * @param < T > The type of resulting data
 * @param type MapreduceType
 * @param q The query (only the criteria, limit and sort will be used)
 * @param outputType The type of resulting data; inline is not working yet
 * @param baseCommand The base command to fill in and send to the server
 * @return counts and stuff
 */
<T>MapreduceResults<T> mapReduce(MapreduceType type,Query q,Class<T> outputType,MapReduceCommand baseCommand);
Program: 104684
Project: 104684
Buggy source:
public DBObject getFieldsObject(){
  if (fields == null || fields.length == 0)   return null;
  Map<String,Integer> fieldsFilter=new HashMap<String,Integer>();
  for (  String field : this.fields) {
    StringBuffer sb=new StringBuffer(field);
    Mapper.validate(clazz,ds.getMapper(),sb,FilterOperator.EQUAL,null,validateName,false);
    field=sb.toString();
    fieldsFilter.put(field,(includeFields ? 1 : 0));
  }
  return new BasicDBObject(fieldsFilter);
}

Fixed version (ground truth):
public DBObject getFieldsObject(){
  if (fields == null || fields.length == 0)   return null;
  Map<String,Integer> fieldsFilter=new HashMap<String,Integer>();
  for (  String field : this.fields) {
    StringBuffer sb=new StringBuffer(field);
    Mapper.validate(clazz,ds.getMapper(),sb,FilterOperator.EQUAL,null,validateName,false);
    field=sb.toString();
    fieldsFilter.put(field,(includeFields ? 1 : 0));
  }
  if (includeFields)   fieldsFilter.put(Mapper.CLASS_NAME_FIELDNAME,1);
  return new BasicDBObject(fieldsFilter);
}
Program: 104685
Project: 104685
Buggy source:
@Override public Object encode(Object value,MappedField mf){
  if (value == null)   return null;
  Iterable<?> iterableValues=null;
  if (value.getClass().isArray()) {
    if (Array.getLength(value) == 0) {
      return value;
    }
    if (value.getClass().getComponentType().isPrimitive())     return value;
    iterableValues=Arrays.asList((Object[])value);
  }
 else {
    if (!(value instanceof Iterable))     throw new ConverterException("String_Node_Str" + value.getClass() + "String_Node_Str"+ mf);
    iterableValues=(Iterable<?>)value;
  }
  List values=new ArrayList();
  if (mf != null && mf.getSubClass() != null) {
    for (    Object o : iterableValues) {
      values.add(chain.encode(mf.getSubClass(),o));
    }
  }
 else {
    for (    Object o : iterableValues) {
      values.add(chain.encode(o));
    }
  }
  if (values.size() > 0) {
    return values;
  }
 else   return null;
}

Fixed version (ground truth):
@Override public Object encode(Object value,MappedField mf){
  if (value == null)   return null;
  Iterable<?> iterableValues=null;
  if (value.getClass().isArray()) {
    if (Array.getLength(value) == 0) {
      return value;
    }
    if (value.getClass().getComponentType().isPrimitive())     return value;
    iterableValues=Arrays.asList((Object[])value);
  }
 else {
    if (!(value instanceof Iterable))     throw new ConverterException("String_Node_Str" + value.getClass() + "String_Node_Str"+ mf);
    iterableValues=(Iterable<?>)value;
  }
  List values=new ArrayList();
  if (mf != null && mf.getSubClass() != null) {
    for (    Object o : iterableValues) {
      values.add(chain.encode(mf.getSubClass(),o));
    }
  }
 else {
    for (    Object o : iterableValues) {
      values.add(chain.encode(o));
    }
  }
  if (values.size() > 0 || mapr.getOptions().storeEmpties) {
    return values;
  }
 else   return null;
}
Program: 104686
Project: 104686
Buggy source:
public List<Key<T>> findIds(Query<T> q){
  return (List<Key<T>>)keysToIds(q.asKeyList());
}

Fixed version (ground truth):
public Lis<T> findIds(Query<T> q){
  return (List<T>)keysToIds(q.asKeyList());
}
Program: 104687
Project: 104687
Buggy source:
/** 
 * Finds the entities Key<T>s by the criteria {key:value}
 */
public List<Key<T>> findIds(Query<T> q);

Fixed version (ground truth):
/** 
 * Finds the entities Ts by the criteria {key:value}
 */
public List<T> findIds(Query<T> q);
Program: 104688
Project: 104688
Buggy source:
/** 
 * Add MappedClass to internal cache, possibly validating first. 
 */
private MappedClass addMappedClass(MappedClass mc,boolean validate){
  if (validate)   mc.validate();
  Converters c=(Converters)mc.getAnnotation(Converters.class);
  if (c != null)   for (  Class<? extends TypeConverter> clazz : c.value())   if (!converters.isRegistered(clazz))   converters.addConverter(clazz);
  mappedClasses.put(mc.getClazz().getName(),mc);
  Set<MappedClass> mcs=mappedClassesByCollection.get(mc.getCollectionName());
  if (mcs == null) {
    mcs=new HashSet();
    mappedClassesByCollection.putIfAbsent(mc.getCollectionName(),mcs);
  }
  mcs.add(mc);
  return mc;
}

Fixed version (ground truth):
/** 
 * Add MappedClass to internal cache, possibly validating first. 
 */
private MappedClass addMappedClass(MappedClass mc,boolean validate){
  if (validate)   mc.validate();
  Converters c=(Converters)mc.getAnnotation(Converters.class);
  if (c != null)   for (  Class<? extends TypeConverter> clazz : c.value())   if (!converters.isRegistered(clazz))   converters.addConverter(clazz);
  mappedClasses.put(mc.getClazz().getName(),mc);
  Set<MappedClass> mcs=mappedClassesByCollection.get(mc.getCollectionName());
  if (mcs == null) {
    mcs=new CopyOnWriteArraySet<MappedClass>();
    Set<MappedClass> temp=mappedClassesByCollection.putIfAbsent(mc.getCollectionName(),mcs);
    if (temp != null)     mcs=temp;
  }
  mcs.add(mc);
  return mc;
}
Program: 104689
Project: 104689
Buggy source:
public T sizeEq(int val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.SIZE,val);
}

Fixed version (ground truth):
public T sizeEq(int val){
  return addCrit(FilterOperator.SIZE,val);
}
Program: 104690
Project: 104690
Buggy source:
@Test public final void testMissingIdNoImplicitMapCall(){
  Key<E> save=ds.save(new E());
  E byKey=ds.getByKey(E.class,save);
}

Fixed version (ground truth):
@Test public final void testMissingIdNoImplicitMapCall(){
  final Key<E> save=ds.save(new E());
  new AssertedFailure(){
    @Override protected void thisMustFail() throws Throwable {
      E byKey=ds.getByKey(E.class,save);
    }
  }
;
}
Program: 104691
Project: 104691
Buggy source:
@Override protected void thisMustFail() throws Throwable {
  morphia.map(E.class);
}

Fixed version (ground truth):
@Override protected void thisMustFail() throws Throwable {
  E byKey=ds.getByKey(E.class,save);
}
Program: 104692
Project: 104692
Buggy source:
public void addTo(DBObject obj){
  if (this.joinMethod == CriteriaJoin.AND) {
    for (    Criteria child : this.children) {
      child.addTo(obj);
    }
  }
 else   if (this.joinMethod == CriteriaJoin.OR) {
    BasicDBList or=new BasicDBList();
    for (    Criteria child : this.children) {
      BasicDBObject container=new BasicDBObject();
      child.addTo(container);
      or.add(container);
    }
    obj.put("String_Node_Str",or);
  }
}

Fixed version (ground truth):
public void addTo(DBObject obj){
  if (this.joinMethod == CriteriaJoin.AND) {
    Set<String> fields=new HashSet<String>();
    int nonNullFieldNames=0;
    for (    Criteria child : this.children) {
      if (null != child.getFieldName()) {
        fields.add(child.getFieldName());
        nonNullFieldNames++;
      }
    }
    if (fields.size() < nonNullFieldNames) {
      BasicDBList and=new BasicDBList();
      for (      Criteria child : this.children) {
        BasicDBObject container=new BasicDBObject();
        child.addTo(container);
        and.add(container);
      }
      obj.put("String_Node_Str",and);
    }
 else {
      for (      Criteria child : this.children) {
        child.addTo(obj);
      }
    }
  }
 else   if (this.joinMethod == CriteriaJoin.OR) {
    BasicDBList or=new BasicDBList();
    for (    Criteria child : this.children) {
      BasicDBObject container=new BasicDBObject();
      child.addTo(container);
      or.add(container);
    }
    obj.put("String_Node_Str",or);
  }
}
Program: 104693
Project: 104693
Buggy source:
public Query<T> queryNonPrimary(){
  slaveOk=true;
  return this;
}

Fixed version (ground truth):
public Query<T> queryNonPrimary(){
  readPref=ReadPreference.SECONDARY;
  return this;
}
Program: 104694
Project: 104694
Buggy source:
public Query<T> queryPrimaryOnly(){
  slaveOk=false;
  return this;
}

Fixed version (ground truth):
public Query<T> queryPrimaryOnly(){
  readPref=ReadPreference.PRIMARY;
  return this;
}
Program: 104695
Project: 104695
Buggy source:
public DBCursor prepareCursor(){
  DBObject query=getQueryObject();
  DBObject fields=getFieldsObject();
  if (log.isTraceEnabled())   log.trace("String_Node_Str" + dbColl.getName() + "String_Node_Str"+ query+ "String_Node_Str"+ fields+ "String_Node_Str"+ offset+ "String_Node_Str"+ limit);
  DBCursor cursor=dbColl.find(query,fields);
  cursor.setDecoderFactory(this.ds.getDecoderFact());
  if (offset > 0)   cursor.skip(offset);
  if (limit > 0)   cursor.limit(limit);
  if (batchSize > 0)   cursor.batchSize(batchSize);
  if (snapshotted)   cursor.snapshot();
  if (sort != null)   cursor.sort(sort);
  if (indexHint != null)   cursor.hint(indexHint);
  if (slaveOk) {
    cursor.addOption(Bytes.QUERYOPTION_SLAVEOK);
  }
  if (noTimeout) {
    cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT);
  }
  if (tail) {
    cursor.addOption(Bytes.QUERYOPTION_TAILABLE);
    if (tail_await_data)     cursor.addOption(Bytes.QUERYOPTION_AWAITDATA);
  }
  if (snapshotted && (sort != null || indexHint != null))   log.warning("String_Node_Str");
  if (tail && (sort != null)) {
    log.warning("String_Node_Str");
  }
  return cursor;
}

Fixed version (ground truth):
public DBCursor prepareCursor(){
  DBObject query=getQueryObject();
  DBObject fields=getFieldsObject();
  if (log.isTraceEnabled())   log.trace("String_Node_Str" + dbColl.getName() + "String_Node_Str"+ query+ "String_Node_Str"+ fields+ "String_Node_Str"+ offset+ "String_Node_Str"+ limit);
  DBCursor cursor=dbColl.find(query,fields);
  cursor.setDecoderFactory(this.ds.getDecoderFact());
  if (offset > 0)   cursor.skip(offset);
  if (limit > 0)   cursor.limit(limit);
  if (batchSize > 0)   cursor.batchSize(batchSize);
  if (snapshotted)   cursor.snapshot();
  if (sort != null)   cursor.sort(sort);
  if (indexHint != null)   cursor.hint(indexHint);
  if (null != readPref) {
    cursor.setReadPreference(readPref);
  }
  if (noTimeout) {
    cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT);
  }
  if (tail) {
    cursor.addOption(Bytes.QUERYOPTION_TAILABLE);
    if (tail_await_data)     cursor.addOption(Bytes.QUERYOPTION_AWAITDATA);
  }
  if (snapshotted && (sort != null || indexHint != null))   log.warning("String_Node_Str");
  if (tail && (sort != null)) {
    log.warning("String_Node_Str");
  }
  return cursor;
}
Program: 104696
Project: 104696
Buggy source:
@Override public QueryImpl<T> clone(){
  QueryImpl<T> n=new QueryImpl<T>(clazz,dbColl,ds);
  n.batchSize=batchSize;
  n.cache=this.ds.getMapper().createEntityCache();
  n.fields=fields == null ? null : Arrays.copyOf(fields,fields.length);
  n.includeFields=includeFields;
  n.indexHint=indexHint;
  n.limit=limit;
  n.noTimeout=noTimeout;
  n.query=n;
  n.offset=offset;
  n.slaveOk=slaveOk;
  n.snapshotted=snapshotted;
  n.validateName=validateName;
  n.validateType=validateType;
  n.sort=(BasicDBObject)(sort == null ? null : sort.clone());
  n.baseQuery=(BasicDBObject)(baseQuery == null ? null : baseQuery.clone());
  n.attachedTo=attachedTo;
  n.children=children == null ? null : new ArrayList<Criteria>(children);
  n.tail=tail;
  n.tail_await_data=tail_await_data;
  return n;
}

Fixed version (ground truth):
@Override public QueryImpl<T> clone(){
  QueryImpl<T> n=new QueryImpl<T>(clazz,dbColl,ds);
  n.batchSize=batchSize;
  n.cache=this.ds.getMapper().createEntityCache();
  n.fields=fields == null ? null : Arrays.copyOf(fields,fields.length);
  n.includeFields=includeFields;
  n.indexHint=indexHint;
  n.limit=limit;
  n.noTimeout=noTimeout;
  n.query=n;
  n.offset=offset;
  n.readPref=readPref;
  n.snapshotted=snapshotted;
  n.validateName=validateName;
  n.validateType=validateType;
  n.sort=(BasicDBObject)(sort == null ? null : sort.clone());
  n.baseQuery=(BasicDBObject)(baseQuery == null ? null : baseQuery.clone());
  n.attachedTo=attachedTo;
  n.children=children == null ? null : new ArrayList<Criteria>(children);
  n.tail=tail;
  n.tail_await_data=tail_await_data;
  return n;
}
Program: 104697
Project: 104697
Buggy source:
public Object getId(Object entity){
  entity=ProxyHelper.unwrap(entity);
  MappedClass mc=getMappedClass(entity.getClass());
  try {
    return mc.getIdField().get(entity);
  }
 catch (  Exception e) {
    return null;
  }
}

Fixed version (ground truth):
public Object getId(Object entity){
  if (entity == null)   return null;
  entity=ProxyHelper.unwrap(entity);
  MappedClass mc=getMappedClass(entity.getClass());
  try {
    return mc.getIdField().get(entity);
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 104699
Project: 104699
Buggy source:
public <T>Key<T> refToKey(DBRef ref){
  Key<T> key=new Key<T>(ref.getRef(),ref.getId());
  return key;
}

Fixed version (ground truth):
public <T>Key<T> refToKey(DBRef ref){
  if (ref == null)   return null;
  Key<T> key=new Key<T>(ref.getRef(),ref.getId());
  return key;
}
Program: 104700
Project: 104700
Buggy source:
public DBRef keyToRef(Key key){
  if (key.getKindClass() == null && key.getKind() == null)   throw new IllegalStateException("String_Node_Str");
  if (key.getKind() == null)   key.setKind(getCollectionName(key.getKindClass()));
  return new DBRef(null,key.getKind(),key.getId());
}

Fixed version (ground truth):
public DBRef keyToRef(Key key){
  if (key == null)   return null;
  if (key.getKindClass() == null && key.getKind() == null)   throw new IllegalStateException("String_Node_Str");
  if (key.getKind() == null)   key.setKind(getCollectionName(key.getKindClass()));
  return new DBRef(null,key.getKind(),key.getId());
}
Program: 104701
Project: 104701
Buggy source:
protected <T>WriteResult tryVersionedUpdate(DBCollection dbColl,T entity,DBObject dbObj,WriteConcern wc,DB db,MappedClass mc){
  WriteResult wr=null;
  if (mc.getFieldsAnnotatedWith(Version.class).isEmpty())   return wr;
  MappedField mfVersion=mc.getFieldsAnnotatedWith(Version.class).get(0);
  String versionKeyName=mfVersion.getNameToStore();
  Long oldVersion=(Long)mfVersion.getFieldValue(entity);
  long newVersion=VersionHelper.nextValue(oldVersion);
  dbObj.put(versionKeyName,newVersion);
  if (oldVersion != null && oldVersion > 0) {
    Object idValue=dbObj.get(Mapper.ID_KEY);
    UpdateResults<T> res=update(find((Class<T>)entity.getClass(),Mapper.ID_KEY,idValue).filter(versionKeyName,oldVersion),dbObj,false,false,wc);
    wr=res.getWriteResult();
    if (res.getUpdatedCount() != 1)     throw new ConcurrentModificationException("String_Node_Str" + entity.getClass().getName() + "String_Node_Str"+ idValue+ "String_Node_Str"+ oldVersion+ "String_Node_Str");
  }
 else   if (wc == null)   wr=dbColl.save(dbObj);
 else   wr=dbColl.save(dbObj,wc);
  mfVersion.setFieldValue(entity,newVersion);
  return wr;
}

Fixed version (ground truth):
protected <T>WriteResult tryVersionedUpdate(DBCollection dbColl,T entity,DBObject dbObj,WriteConcern wc,DB db,MappedClass mc){
  WriteResult wr=null;
  if (mc.getFieldsAnnotatedWith(Version.class).isEmpty())   return wr;
  MappedField mfVersion=mc.getFieldsAnnotatedWith(Version.class).get(0);
  String versionKeyName=mfVersion.getNameToStore();
  Long oldVersion=(Long)mfVersion.getFieldValue(entity);
  long newVersion=VersionHelper.nextValue(oldVersion);
  dbObj.put(versionKeyName,newVersion);
  if (oldVersion != null && oldVersion > 0) {
    Object idValue=dbObj.get(Mapper.ID_KEY);
    UpdateResults<T> res=update(find(dbColl.getName(),(Class<T>)entity.getClass()).filter(Mapper.ID_KEY,idValue).filter(versionKeyName,oldVersion),dbObj,false,false,wc);
    wr=res.getWriteResult();
    if (res.getUpdatedCount() != 1)     throw new ConcurrentModificationException("String_Node_Str" + entity.getClass().getName() + "String_Node_Str"+ idValue+ "String_Node_Str"+ oldVersion+ "String_Node_Str");
  }
 else   if (wc == null)   wr=dbColl.save(dbObj);
 else   wr=dbColl.save(dbObj,wc);
  mfVersion.setFieldValue(entity,newVersion);
  return wr;
}
Program: 104702
Project: 104702
Buggy source:
public <T>Query<T> queryByExample(T ex){
  return new QueryImpl<T>((Class<T>)ex.getClass(),getCollection(ex),this,entityToDBObj(ex,new HashMap<Object,DBObject>()));
}

Fixed version (ground truth):
private <T>Query<T> queryByExample(DBCollection coll,T example){
  return new QueryImpl<T>((Class<T>)example.getClass(),coll,this,entityToDBObj(example,new HashMap<Object,DBObject>()));
}
Program: 104703
Project: 104703
Buggy source:
<T>Iterable<Key<T>> insert(Iterable<T> entities,WriteConcern wc);

Fixed version (ground truth):
<T>Iterable<Key<T>> insert(String kind,Iterable<T> entities,WriteConcern wc);
Program: 104704
Project: 104704
Buggy source:
public static long nextValue(Long oldVersion){
  long currentTimeMillis=System.currentTimeMillis();
  if (oldVersion != null && oldVersion.longValue() == currentTimeMillis)   currentTimeMillis++;
  return currentTimeMillis;
}

Fixed version (ground truth):
public static long nextValue(Long oldVersion){
  long newVersion=oldVersion == null ? 1 : oldVersion + 1;
  return newVersion;
}
Program: 104705
Project: 104705
Buggy source:
public WriteResult deleteByQuery(Query q){
  return ds.delete(q);
}

Fixed version (ground truth):
public WriteResult deleteByQuery(Query<T> q){
  return ds.delete(q);
}
Program: 104706
Project: 104706
Buggy source:
/** 
 * Returns an tailing iterator over a set of elements of type T. If awaitData is true, this iterator blocks on hasNext() until new data is avail. Note that if no data is available  at all, hasNext() might return immediately.
 * @return an Iterator.
 */
Iterator<T> tail(boolean awaitData);

Fixed version (ground truth):
/** 
 * Returns an tailing iterator over a set of elements of type T. If awaitData is true, this iterator blocks on hasNext() until new data is avail (or some amount of time has passed). Note that if no data is available  at all, hasNext() might return immediately. You should wrap tail calls in a loop if you want this to be blocking.
 * @return an Iterator.
 */
Iterator<T> tail(boolean awaitData);
Program: 104707
Project: 104707
Buggy source:
public T near(double x,double y,boolean spherical){
  return addGeoCrit(FilterOperator.NEAR,new double[]{x,y},spherical ? opts("String_Node_Str",true) : null);
}

Fixed version (ground truth):
public T near(double x,double y,boolean spherical){
  return addGeoCrit(spherical ? FilterOperator.NEAR_SPHERE : FilterOperator.NEAR,new double[]{x,y},null);
}
Program: 104708
Project: 104708
Buggy source:
@Override public void addTo(DBObject obj){
  BasicDBObjectBuilder query=null;
switch (operator) {
case NEAR:
    query=BasicDBObjectBuilder.start(FilterOperator.NEAR.val(),value);
  break;
case WITHIN_BOX:
query=BasicDBObjectBuilder.start().push(FilterOperator.WITHIN.val()).add(operator.val(),value);
break;
case WITHIN_CIRCLE:
query=BasicDBObjectBuilder.start().push(FilterOperator.WITHIN.val()).add(operator.val(),value);
break;
default :
throw new UnsupportedOperationException(operator + "String_Node_Str");
}
if (opts != null) for (Map.Entry<String,Object> e : opts.entrySet()) query.append(e.getKey(),e.getValue());
obj.put(field,query.get());
}

Fixed version (ground truth):
@Override public void addTo(DBObject obj){
  BasicDBObjectBuilder query=null;
switch (operator) {
case NEAR:
    query=BasicDBObjectBuilder.start(FilterOperator.NEAR.val(),value);
  break;
case NEAR_SPHERE:
query=BasicDBObjectBuilder.start(FilterOperator.NEAR_SPHERE.val(),value);
break;
case WITHIN_BOX:
query=BasicDBObjectBuilder.start().push(FilterOperator.WITHIN.val()).add(operator.val(),value);
break;
case WITHIN_CIRCLE:
query=BasicDBObjectBuilder.start().push(FilterOperator.WITHIN.val()).add(operator.val(),value);
break;
case WITHIN_CIRCLE_SPHERE:
query=BasicDBObjectBuilder.start().push(FilterOperator.WITHIN.val()).add(operator.val(),value);
break;
default :
throw new UnsupportedOperationException(operator + "String_Node_Str");
}
if (opts != null) for (Map.Entry<String,Object> e : opts.entrySet()) query.append(e.getKey(),e.getValue());
obj.put(field,query.get());
}
Program: 104709
Project: 104709
Buggy source:
/** 
 * <p>Compares based on the following traits, in order:</p> <ol> <li>kind/kindClass</li> <li>parent</li> <li>id or name</li> </ol>
 */
@SuppressWarnings("String_Node_Str") public int compareTo(Key<?> other){
  checkState(this);
  checkState(other);
  int cmp=0;
  if (other.kindClass != null && kindClass != null) {
    cmp=this.kindClass.getName().compareTo(other.kindClass.getName());
    if (cmp != 0)     return cmp;
  }
  cmp=compareNullable(this.kind,other.kind);
  if (cmp != 0)   return cmp;
  try {
    cmp=compareNullable((Comparable<?>)this.id,(Comparable<?>)other.id);
    if (cmp != 0)     return cmp;
  }
 catch (  Exception e) {
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * <p> Compares based on the following traits, in order: </p> <ol> <li>kind/kindClass</li> <li>parent</li> <li>id or name</li> </ol>
 */
@SuppressWarnings("String_Node_Str") public int compareTo(Key<?> other){
  checkState(this);
  checkState(other);
  int cmp=0;
  if (other.kindClass != null && kindClass != null) {
    cmp=this.kindClass.getName().compareTo(other.kindClass.getName());
    if (cmp != 0)     return cmp;
  }
  cmp=compareNullable(this.kind,other.kind);
  if (cmp != 0)   return cmp;
  try {
    cmp=compareNullable((Comparable<?>)this.id,(Comparable<?>)other.id);
    if (cmp != 0)     return cmp;
  }
 catch (  Exception e) {
    cmp=this.id.equals(other.id) ? 0 : 1;
    if (cmp != 0)     return this.id.toString().compareTo(other.id.toString());
  }
  return 0;
}
Program: 104710
Project: 104710
Buggy source:
public DBObject getFieldsObject(){
  if (fields == null || fields.length == 0)   return null;
  Map<String,Boolean> fieldsFilter=new HashMap<String,Boolean>();
  for (  String field : this.fields) {
    StringBuffer sb=new StringBuffer(field);
    Mapper.validate(clazz,ds.getMapper(),sb,FilterOperator.EQUAL,null,validateName,false);
    field=sb.toString();
    fieldsFilter.put(field,(includeFields));
  }
  return new BasicDBObject(fieldsFilter);
}

Fixed version (ground truth):
public DBObject getFieldsObject(){
  if (fields == null || fields.length == 0)   return null;
  Map<String,Integer> fieldsFilter=new HashMap<String,Integer>();
  for (  String field : this.fields) {
    StringBuffer sb=new StringBuffer(field);
    Mapper.validate(clazz,ds.getMapper(),sb,FilterOperator.EQUAL,null,validateName,false);
    field=sb.toString();
    fieldsFilter.put(field,(includeFields ? 1 : 0));
  }
  return new BasicDBObject(fieldsFilter);
}
Program: 104711
Project: 104711
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))) || (mc != null && mc.getEntityAnnotation() != null)) {
    try {
      Key<?> k=(value instanceof Key) ? (Key<?>)value : getKey(value);
      mappedValue=keyToRef(k);
    }
 catch (    Exception e) {
      log.debug("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.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;
}
Program: 104712
Project: 104712
Buggy source:
public Query<T> order(String condition){
  if (snapshotted)   throw new QueryException("String_Node_Str");
  sort=parseFieldsString(condition,clazz,this.ds.getMapper(),this.validateName);
  return this;
}

Fixed version (ground truth):
public Query<T> order(String condition){
  if (snapshotted)   throw new QueryException("String_Node_Str");
  if (condition == null || condition.trim() == "String_Node_Str")   sort=null;
  sort=parseFieldsString(condition,clazz,this.ds.getMapper(),this.validateName);
  return this;
}
Program: 104713
Project: 104713
Buggy source:
/** 
 * parses the string and validates each part
 */
public static BasicDBObject parseFieldsString(String str,Class clazz,Mapper mapr,boolean validate){
  BasicDBObjectBuilder ret=BasicDBObjectBuilder.start();
  String[] parts=str.split("String_Node_Str");
  for (  String s : parts) {
    s=s.trim();
    int dir=1;
    if (s.startsWith("String_Node_Str")) {
      dir=-1;
      s=s.substring(1).trim();
    }
    if (validate) {
      StringBuffer sb=new StringBuffer(s);
      Mapper.validate(clazz,mapr,sb,FilterOperator.IN,"String_Node_Str",true,false);
      s=sb.toString();
    }
    ret=ret.add(s,dir);
  }
  return (BasicDBObject)ret.get();
}

Fixed version (ground truth):
/** 
 * parses the string and validates each part
 */
@SuppressWarnings("String_Node_Str") public static BasicDBObject parseFieldsString(String str,Class clazz,Mapper mapr,boolean validate){
  BasicDBObjectBuilder ret=BasicDBObjectBuilder.start();
  String[] parts=str.split("String_Node_Str");
  for (  String s : parts) {
    s=s.trim();
    int dir=1;
    if (s.startsWith("String_Node_Str")) {
      dir=-1;
      s=s.substring(1).trim();
    }
    if (validate) {
      StringBuffer sb=new StringBuffer(s);
      Mapper.validate(clazz,mapr,sb,FilterOperator.IN,"String_Node_Str",true,false);
      s=sb.toString();
    }
    ret=ret.add(s,dir);
  }
  return (BasicDBObject)ret.get();
}
Program: 104714
Project: 104714
Buggy source:
public DBObject getQueryObject(){
  DBObject obj=new BasicDBObject();
  if (this.baseQuery != null) {
    obj.putAll(this.baseQuery);
  }
  this.addTo(obj);
  return obj;
}

Fixed version (ground truth):
public DBObject getQueryObject(){
  DBObject obj=new BasicDBObject();
  if (this.baseQuery != null) {
    obj.putAll((BSONObject)this.baseQuery);
  }
  this.addTo(obj);
  return obj;
}
Program: 104715
Project: 104715
Buggy source:
public QueryImpl(Class<T> clazz,DBCollection coll,DatastoreImpl ds,DBObject baseQuery){
  this(clazz,coll,ds);
  this.baseQuery=baseQuery;
}

Fixed version (ground truth):
public QueryImpl(Class<T> clazz,DBCollection coll,DatastoreImpl ds,DBObject baseQuery){
  this(clazz,coll,ds);
  this.baseQuery=(BasicDBObject)baseQuery;
}
Program: 104716
Project: 104716
Buggy source:
public void setQueryObject(DBObject query){
  this.baseQuery=query;
}

Fixed version (ground truth):
public void setQueryObject(DBObject query){
  this.baseQuery=(BasicDBObject)query;
}
Program: 104717
Project: 104717
Buggy source:
@Override public QueryImpl<T> clone(){
  QueryImpl<T> n=new QueryImpl<T>(clazz,dbColl,ds);
  n.batchSize=batchSize;
  n.cache=this.ds.getMapper().createEntityCache();
  n.fields=fields == null ? null : Arrays.copyOf(fields,fields.length);
  n.includeFields=includeFields;
  n.indexHint=indexHint;
  n.limit=limit;
  n.noTimeout=noTimeout;
  n.query=n;
  n.offset=offset;
  n.slaveOk=slaveOk;
  n.snapshotted=snapshotted;
  n.validateName=validateName;
  n.validateType=validateType;
  n.sort=(DBObject)(sort == null ? null : ((BasicDBObject)sort).clone());
  n.baseQuery=(DBObject)(baseQuery == null ? null : ((BasicDBObject)baseQuery).clone());
  n.attachedTo=attachedTo;
  n.children=children == null ? null : new ArrayList<Criteria>(children);
  n.tail=tail;
  n.tail_await_data=tail_await_data;
  return n;
}

Fixed version (ground truth):
@Override public QueryImpl<T> clone(){
  QueryImpl<T> n=new QueryImpl<T>(clazz,dbColl,ds);
  n.batchSize=batchSize;
  n.cache=this.ds.getMapper().createEntityCache();
  n.fields=fields == null ? null : Arrays.copyOf(fields,fields.length);
  n.includeFields=includeFields;
  n.indexHint=indexHint;
  n.limit=limit;
  n.noTimeout=noTimeout;
  n.query=n;
  n.offset=offset;
  n.slaveOk=slaveOk;
  n.snapshotted=snapshotted;
  n.validateName=validateName;
  n.validateType=validateType;
  n.sort=(BasicDBObject)(sort == null ? null : sort.clone());
  n.baseQuery=(BasicDBObject)(baseQuery == null ? null : baseQuery.clone());
  n.attachedTo=attachedTo;
  n.children=children == null ? null : new ArrayList<Criteria>(children);
  n.tail=tail;
  n.tail_await_data=tail_await_data;
  return n;
}
Program: 104718
Project: 104718
Buggy source:
public static boolean isPropertyType(final Class type){
  if (type == null) {
    return false;
  }
  return isPrimitiveLike(type) || (type == DBRef.class) || (type == Pattern.class)|| (type == CodeWScope.class)|| (type == ObjectId.class)|| (type == Key.class);
}

Fixed version (ground truth):
public static boolean isPropertyType(final Class type){
  if (type == null) {
    return false;
  }
  return isPrimitiveLike(type) || (type == DBRef.class) || (type == Pattern.class)|| (type == CodeWScope.class)|| (type == ObjectId.class)|| (type == Key.class)|| (type == DBObject.class)|| (type == BasicDBObject.class);
}
Program: 104719
Project: 104719
Buggy source:
public DefaultConverters(){
  addConverter(new PassthroughConverter(DBObject.class,BasicDBObject.class));
  addConverter(new PassthroughConverter(byte[].class));
  addConverter(new EnumSetConverter());
  addConverter(new EnumConverter());
  addConverter(new StringConverter());
  addConverter(new CharacterConverter());
  addConverter(new ByteConverter());
  addConverter(new BooleanConverter());
  addConverter(new DoubleConverter());
  addConverter(new FloatConverter());
  addConverter(new LongConverter());
  addConverter(new LocaleConverter());
  addConverter(new ShortConverter());
  addConverter(new IntegerConverter());
  addConverter(new SerializedObjectConverter());
  addConverter(new CharArrayConverter());
  addConverter(new DateConverter());
  addConverter(new KeyConverter());
  addConverter(new MapOfValuesConverter(this));
  addConverter(new IterableConverter(this));
  addConverter(new ClassConverter());
  addConverter(new ObjectIdConverter());
  addConverter(new TimestampConverter());
  addConverter(new PassthroughConverter());
}

Fixed version (ground truth):
public DefaultConverters(){
  addConverter(new PassthroughConverter(DBObject.class,BasicDBObject.class));
  addConverter(new PassthroughConverter(byte[].class));
  addConverter(new EnumSetConverter());
  addConverter(new EnumConverter());
  addConverter(new StringConverter());
  addConverter(new CharacterConverter());
  addConverter(new ByteConverter());
  addConverter(new BooleanConverter());
  addConverter(new DoubleConverter());
  addConverter(new FloatConverter());
  addConverter(new LongConverter());
  addConverter(new LocaleConverter());
  addConverter(new ShortConverter());
  addConverter(new IntegerConverter());
  addConverter(new SerializedObjectConverter());
  addConverter(new CharArrayConverter());
  addConverter(new DateConverter());
  addConverter(new URIConverter());
  addConverter(new KeyConverter());
  addConverter(new MapOfValuesConverter(this));
  addConverter(new IterableConverter(this));
  addConverter(new ClassConverter());
  addConverter(new ObjectIdConverter());
  addConverter(new TimestampConverter());
  addConverter(new PassthroughConverter());
}
Program: 104720
Project: 104720
Buggy source:
public static boolean isPrimitiveLike(final Class type){
  if (type == null) {
    return false;
  }
  return (type == String.class) || (type == char.class) || (type == Character.class)|| (type == short.class)|| (type == Short.class)|| (type == Integer.class)|| (type == int.class)|| (type == Long.class)|| (type == long.class)|| (type == Double.class)|| (type == double.class)|| (type == float.class)|| (type == Float.class)|| (type == Boolean.class)|| (type == boolean.class)|| (type == Byte.class)|| (type == byte.class)|| (type == Date.class)|| (type == Locale.class)|| (type == Class.class)|| (type == UUID.class)|| type.isEnum();
}

Fixed version (ground truth):
public static boolean isPrimitiveLike(final Class type){
  if (type == null) {
    return false;
  }
  return (type == String.class) || (type == char.class) || (type == Character.class)|| (type == short.class)|| (type == Short.class)|| (type == Integer.class)|| (type == int.class)|| (type == Long.class)|| (type == long.class)|| (type == Double.class)|| (type == double.class)|| (type == float.class)|| (type == Float.class)|| (type == Boolean.class)|| (type == boolean.class)|| (type == Byte.class)|| (type == byte.class)|| (type == Date.class)|| (type == Locale.class)|| (type == Class.class)|| (type == UUID.class)|| (type == URI.class)|| type.isEnum();
}
Program: 104721
Project: 104721
Buggy source:
public <T>Key<T> merge(T entity,WriteConcern wc){
  LinkedHashMap<Object,DBObject> involvedObjects=new LinkedHashMap<Object,DBObject>();
  DBObject dbObj=mapr.toDBObject(entity,involvedObjects);
  Key<T> key=getKey(entity);
  entity=ProxyHelper.unwrap(entity);
  Object id=getId(entity);
  if (id == null)   throw new MappingException("String_Node_Str" + entity.getClass().getName());
  Query<T> query=(Query<T>)createQuery(entity.getClass()).filter(Mapper.ID_KEY,id);
  dbObj.removeField(Mapper.ID_KEY);
  UpdateResults<T> res=update(query,new BasicDBObject("String_Node_Str",dbObj),false,false,wc);
  CommandResult gle=res.getWriteResult().getCachedLastError();
  if (gle != null && res.getUpdatedCount() == 0)   throw new UpdateException("String_Node_Str" + gle);
  postSaveOperations(entity,dbObj,involvedObjects);
  return key;
}

Fixed version (ground truth):
public <T>Key<T> merge(T entity,WriteConcern wc){
  LinkedHashMap<Object,DBObject> involvedObjects=new LinkedHashMap<Object,DBObject>();
  DBObject dbObj=mapr.toDBObject(entity,involvedObjects);
  Key<T> key=getKey(entity);
  entity=ProxyHelper.unwrap(entity);
  Object id=getId(entity);
  if (id == null)   throw new MappingException("String_Node_Str" + entity.getClass().getName());
  dbObj.removeField(Mapper.ID_KEY);
  WriteResult wr=null;
  MappedClass mc=mapr.getMappedClass(entity);
  DBCollection dbColl=getCollection(entity);
  wr=tryVersionedUpdate(dbColl,entity,dbObj,wc,db,mc);
  if (wr == null) {
    Query<T> query=(Query<T>)createQuery(entity.getClass()).filter(Mapper.ID_KEY,id);
    wr=update(query,new BasicDBObject("String_Node_Str",dbObj),false,false,wc).getWriteResult();
  }
  UpdateResults<T> res=new UpdateResults<T>(wr);
  throwOnError(wc,wr);
  CommandResult gle=wr.getCachedLastError();
  if (gle != null && res.getUpdatedCount() == 0)   throw new UpdateException("String_Node_Str" + gle);
  postSaveOperations(entity,dbObj,involvedObjects);
  return key;
}
Program: 104722
Project: 104722
Buggy source:
public void thisMustFail() throws Throwable {
  ds.save(a1);
}

Fixed version (ground truth):
public void thisMustFail() throws Throwable {
  ds.merge(a1);
}