nus-yam/ex-repair huggingface dataset:
Program: 104779
Project: 104779
Buggy source:
public Query<T> order(String condition){
  if (snapshotted)   throw new QueryException("String_Node_Str");
  sort=parseSortString(condition);
  return this;
}

Fixed version (ground truth):
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;
}
Program: 104780
Project: 104780
Buggy source:
@Test public void testIdFieldNameMapping() throws Exception {
  Rectangle r=new Rectangle(1,12);
  BasicDBObject dbObj=(BasicDBObject)morphia.toDBObject(r);
  assertFalse(dbObj.containsField("String_Node_Str"));
  assertTrue(dbObj.containsField(Mapper.ID_KEY));
  assertTrue(dbObj.containsField("String_Node_Str"));
  assertTrue(dbObj.containsField("String_Node_Str"));
  assertEquals(4,dbObj.size());
}

Fixed version (ground truth):
@Test public void testIdFieldNameMapping() throws Exception {
  Rectangle r=new Rectangle(1,12);
  BasicDBObject dbObj=(BasicDBObject)morphia.toDBObject(r);
  assertFalse(dbObj.containsField("String_Node_Str"));
  assertTrue(dbObj.containsField(Mapper.ID_KEY));
  assertEquals(4,dbObj.size());
}
Program: 104781
Project: 104781
Buggy source:
@Override public String toString(){
  StringBuffer sb=new StringBuffer();
  sb.append(name).append("String_Node_Str");
  sb.append("String_Node_Str").append(realType.getSimpleName()).append("String_Node_Str");
  if (isSingleValue())   sb.append("String_Node_Str");
 else {
    sb.append("String_Node_Str");
    sb.append("String_Node_Str").append(getSubClass()).append("String_Node_Str");
  }
  if (isMap()) {
    sb.append("String_Node_Str");
    sb.append("String_Node_Str").append(getMapKeyClass().getSimpleName());
  }
  if (isSet())   sb.append("String_Node_Str");
  if (isCollection)   sb.append("String_Node_Str");
  if (isArray)   sb.append("String_Node_Str");
  if (sb.charAt(sb.length() - 1) == ',')   sb.setLength(sb.length() - 1);
  sb.append("String_Node_Str").append(this.foundAnnotations.toString());
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sb=new StringBuffer();
  sb.append(name).append("String_Node_Str");
  sb.append("String_Node_Str").append(realType.getSimpleName()).append("String_Node_Str");
  if (isSingleValue())   sb.append("String_Node_Str");
 else {
    sb.append("String_Node_Str");
    sb.append("String_Node_Str").append(getSubClass()).append("String_Node_Str");
  }
  if (isMap()) {
    sb.append("String_Node_Str");
    if (getMapKeyClass() != null)     sb.append("String_Node_Str").append(getMapKeyClass().getSimpleName());
 else     sb.append("String_Node_Str");
  }
  if (isSet())   sb.append("String_Node_Str");
  if (isCollection)   sb.append("String_Node_Str");
  if (isArray)   sb.append("String_Node_Str");
  if (sb.charAt(sb.length() - 1) == ',')   sb.setLength(sb.length() - 1);
  sb.append("String_Node_Str").append(this.foundAnnotations.toString());
  return sb.toString();
}
Program: 104782
Project: 104782
Buggy source:
protected DAO(Datastore ds){
  this.ds=(DatastoreImpl)ds;
  initType(((Class<T>)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0]));
}

Fixed version (ground truth):
public DAO(Class<T> entityClass,Datastore ds){
  super(entityClass,ds);
}
Program: 104783
Project: 104783
Buggy source:
@Override public String toString(){
  return this.field + "String_Node_Str" + this.value;
}

Fixed version (ground truth):
@Override public String toString(){
  return this.field + "String_Node_Str" + this.operator.val()+ "String_Node_Str"+ this.value;
}
Program: 104785
Project: 104785
Buggy source:
public T endsWithIgnoreCase(String suffix){
  return this.endsWithIgnoreCase(suffix,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T endsWithIgnoreCase(String suffix){
  Assert.parametersNotNull("String_Node_Str",suffix);
  return addCrit(FilterOperator.EQUAL,Pattern.compile(suffix + "String_Node_Str",Pattern.CASE_INSENSITIVE));
}
Program: 104786
Project: 104786
Buggy source:
public T hasAllOf(Iterable<?> vals){
  return this.hasAllOf(vals,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T hasAllOf(Iterable<?> vals){
  Assert.parametersNotNull("String_Node_Str",vals);
  Assert.parameterNotEmpty(vals,"String_Node_Str");
  return addCrit(FilterOperator.ALL,vals);
}
Program: 104787
Project: 104787
Buggy source:
public T hasThisOne(Object val){
  return this.hasThisOne(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T hasThisOne(Object val){
  return addCrit(FilterOperator.EQUAL,val);
}
Program: 104788
Project: 104788
Buggy source:
public T in(Iterable<?> vals){
  return this.hasAnyOf(vals,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T in(Iterable<?> vals){
  return this.hasAnyOf(vals);
}
Program: 104789
Project: 104789
Buggy source:
public T hasThisElement(Object val){
  return this.hasThisElement(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T hasThisElement(Object val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.ELEMENT_MATCH,val);
}
Program: 104790
Project: 104790
Buggy source:
public T lessThanOrEq(Object val){
  return this.lessThanOrEq(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T lessThanOrEq(Object val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.LESS_THAN_OR_EQUAL,val);
}
Program: 104791
Project: 104791
Buggy source:
public T notEqual(Object val){
  return this.notEqual(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T notEqual(Object val){
  return addCrit(FilterOperator.NOT_EQUAL,val);
}
Program: 104792
Project: 104792
Buggy source:
public T containsIgnoreCase(String string){
  return this.containsIgnoreCase(string,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T containsIgnoreCase(String string){
  Assert.parametersNotNull("String_Node_Str",string);
  return addCrit(FilterOperator.EQUAL,Pattern.compile(string,Pattern.CASE_INSENSITIVE));
}
Program: 104793
Project: 104793
Buggy source:
public T greaterThanOrEq(Object val){
  return this.greaterThanOrEq(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T greaterThanOrEq(Object val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.GREATER_THAN_OR_EQUAL,val);
}
Program: 104794
Project: 104794
Buggy source:
public T equal(Object val){
  return this.equal(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T equal(Object val){
  return addCrit(FilterOperator.EQUAL,val);
}
Program: 104795
Project: 104795
Buggy source:
public T sizeEq(int val){
  return this.sizeEq(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T sizeEq(int val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.SIZE,val);
}
Program: 104796
Project: 104796
Buggy source:
public T contains(String string){
  return this.contains(string,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T contains(String string){
  Assert.parametersNotNull("String_Node_Str",string);
  return addCrit(FilterOperator.EQUAL,Pattern.compile(string));
}
Program: 104797
Project: 104797
Buggy source:
public T hasAnyOf(Iterable<?> vals){
  return this.hasAnyOf(vals,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T hasAnyOf(Iterable<?> vals){
  Assert.parametersNotNull("String_Node_Str",vals);
  Assert.parameterNotEmpty(vals,"String_Node_Str");
  return addCrit(FilterOperator.IN,vals);
}
Program: 104798
Project: 104798
Buggy source:
public T doesNotExist(){
  this.target.add(new FieldCriteria(this.query,this.field,FilterOperator.EXISTS,false,this.validateName,this.query.isValidatingTypes()));
  return this.target;
}

Fixed version (ground truth):
public T doesNotExist(){
  return addCrit(FilterOperator.EXISTS,false);
}
Program: 104799
Project: 104799
Buggy source:
public T lessThan(Object val){
  return this.lessThan(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T lessThan(Object val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.LESS_THAN,val);
}
Program: 104800
Project: 104800
Buggy source:
public T endsWith(String suffix){
  return this.endsWith(suffix,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T endsWith(String suffix){
  Assert.parametersNotNull("String_Node_Str",suffix);
  return addCrit(FilterOperator.EQUAL,Pattern.compile(suffix + "String_Node_Str"));
}
Program: 104801
Project: 104801
Buggy source:
public T exists(){
  this.target.add(new FieldCriteria(this.query,this.field,FilterOperator.EXISTS,true,this.validateName,this.query.isValidatingTypes()));
  return this.target;
}

Fixed version (ground truth):
public T exists(){
  return addCrit(FilterOperator.EXISTS,true);
}
Program: 104802
Project: 104802
Buggy source:
public T notIn(Iterable<?> vals){
  return this.hasNoneOf(vals,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T notIn(Iterable<?> vals){
  return this.hasNoneOf(vals);
}
Program: 104803
Project: 104803
Buggy source:
public T near(int x,int y){
  return this.near(x,y,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T near(double x1,double y1,double x2,double y2){
  throw new RuntimeException();
}
Program: 104804
Project: 104804
Buggy source:
public T hasNoneOf(Iterable<?> vals){
  return this.hasNoneOf(vals,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T hasNoneOf(Iterable<?> vals){
  Assert.parametersNotNull("String_Node_Str",vals);
  Assert.parameterNotEmpty(vals,"String_Node_Str");
  return addCrit(FilterOperator.NOT_IN,vals);
}
Program: 104805
Project: 104805
Buggy source:
public T startsWithIgnoreCase(String prefix){
  return this.startsWithIgnoreCase(prefix,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T startsWithIgnoreCase(String prefix){
  Assert.parametersNotNull("String_Node_Str",prefix);
  return addCrit(FilterOperator.EQUAL,Pattern.compile("String_Node_Str" + prefix,Pattern.CASE_INSENSITIVE));
}
Program: 104806
Project: 104806
Buggy source:
public T startsWith(String prefix){
  return this.startsWith(prefix,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T startsWith(String prefix){
  Assert.parametersNotNull("String_Node_Str",prefix);
  return addCrit(FilterOperator.EQUAL,Pattern.compile("String_Node_Str" + prefix));
}
Program: 104807
Project: 104807
Buggy source:
public T greaterThan(Object val){
  return this.greaterThan(val,this.query.isValidatingTypes());
}

Fixed version (ground truth):
public T greaterThan(Object val){
  Assert.parametersNotNull("String_Node_Str",val);
  return addCrit(FilterOperator.GREATER_THAN,val);
}
Program: 104810
Project: 104810
Buggy source:
@Override public Object decode(Class targetClass,Object fromDBObject,MappedField mf) throws MappingException {
  if (mf == null || fromDBObject == null)   return fromDBObject;
  Class subtypeDest=mf.getSubClass();
  Collection vals=null;
  if (fromDBObject.getClass().isArray()) {
    vals=new ArrayList();
    for (    Object o : (Object[])fromDBObject)     vals.add(chain.decode((subtypeDest != null) ? subtypeDest : o.getClass(),o));
  }
 else   if (fromDBObject instanceof Iterable) {
    vals=createNewCollection(mf);
    for (    Object o : (Iterable)fromDBObject)     vals.add(chain.decode((subtypeDest != null) ? subtypeDest : o.getClass(),o));
  }
  if (mf.getType().isArray()) {
    return ReflectionUtils.convertToArray(subtypeDest,(ArrayList)vals);
  }
 else   return vals;
}

Fixed version (ground truth):
@Override public Object decode(Class targetClass,Object fromDBObject,MappedField mf) throws MappingException {
  if (mf == null || fromDBObject == null)   return fromDBObject;
  Class subtypeDest=mf.getSubClass();
  Collection vals=createNewCollection(mf);
  if (fromDBObject.getClass().isArray()) {
    for (    Object o : (Object[])fromDBObject)     vals.add(chain.decode((subtypeDest != null) ? subtypeDest : o.getClass(),o));
  }
 else   if (fromDBObject instanceof Iterable) {
    for (    Object o : (Iterable)fromDBObject)     vals.add(chain.decode((subtypeDest != null) ? subtypeDest : o.getClass(),o));
  }
 else {
    vals.add(chain.decode((subtypeDest != null) ? subtypeDest : fromDBObject.getClass(),fromDBObject));
  }
  if (mf.getType().isArray()) {
    return ReflectionUtils.convertToArray(subtypeDest,(ArrayList)vals);
  }
 else   return vals;
}
Program: 104811
Project: 104811
Buggy source:
public Object createInstance(MappedField mf,DBObject dbObj);

Fixed version (ground truth):
public Object createInstance(Mapper mapr,MappedField mf,DBObject dbObj);
Program: 104812
Project: 104812
Buggy source:
public Object createInstance(MappedField mf,DBObject dbObj){
  return createInstance(mf.getConcreteType(),dbObj);
}

Fixed version (ground truth):
public Object createInstance(Mapper mapr,MappedField mf,DBObject dbObj){
  Class c=getClass(dbObj);
  if (c == null)   c=mf.isSingleValue ? mf.getConcreteType() : mf.getSubClass();
  try {
    return createInstance(c,dbObj);
  }
 catch (  RuntimeException e) {
    ConstructorArgs argAnn=mf.getAnnotation(ConstructorArgs.class);
    if (argAnn == null)     throw e;
    Object[] args=new Object[argAnn.value().length];
    Class[] argTypes=new Class[argAnn.value().length];
    for (int i=0; i < argAnn.value().length; i++) {
      Object val=dbObj.get(argAnn.value()[i]);
      args[i]=val;
      argTypes[i]=val.getClass();
    }
    try {
      Constructor ctor=c.getDeclaredConstructor(argTypes);
      ctor.setAccessible(true);
      return ctor.newInstance(args);
    }
 catch (    Exception ex) {
      throw new RuntimeException(ex);
    }
  }
}
Program: 104813
Project: 104813
Buggy source:
public void fromDBObject(final DBObject dbObject,final MappedField mf,final Object entity,EntityCache cache,Mapper mapr){
  try {
    if (mf.isMap()) {
      readMap(dbObject,mf,entity,cache,mapr);
    }
 else     if (mf.isMultipleValues()) {
      readCollection(dbObject,mf,entity,cache,mapr);
    }
 else {
      Object dbVal=mf.getDbObjectValue(dbObject);
      if (dbVal != null) {
        boolean isDBObject=dbVal instanceof DBObject;
        if (isDBObject && (mapr.converters.hasDbObjectConverter(mf) || mapr.converters.hasDbObjectConverter(mf.getType()))) {
          mapr.converters.fromDBObject(((DBObject)dbVal),mf,entity);
          return;
        }
 else {
          Object refObj=null;
          if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(mf.getType()))           refObj=mapr.converters.decode(mf.getType(),dbVal,mf);
 else {
            refObj=mapr.getOptions().objectFactory.createInstance(mf,((DBObject)dbVal));
            refObj=mapr.fromDb(((DBObject)dbVal),refObj,cache);
          }
          if (refObj != null) {
            mf.setFieldValue(entity,refObj);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void fromDBObject(final DBObject dbObject,final MappedField mf,final Object entity,EntityCache cache,Mapper mapr){
  try {
    if (mf.isMap()) {
      readMap(dbObject,mf,entity,cache,mapr);
    }
 else     if (mf.isMultipleValues()) {
      readCollection(dbObject,mf,entity,cache,mapr);
    }
 else {
      Object dbVal=mf.getDbObjectValue(dbObject);
      if (dbVal != null) {
        boolean isDBObject=dbVal instanceof DBObject;
        if (isDBObject && (mapr.converters.hasDbObjectConverter(mf) || mapr.converters.hasDbObjectConverter(mf.getType()))) {
          mapr.converters.fromDBObject(((DBObject)dbVal),mf,entity);
          return;
        }
 else {
          Object refObj=null;
          if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(mf.getType()))           refObj=mapr.converters.decode(mf.getType(),dbVal,mf);
 else {
            refObj=mapr.getOptions().objectFactory.createInstance(mapr,mf,((DBObject)dbVal));
            refObj=mapr.fromDb(((DBObject)dbVal),refObj,cache);
          }
          if (refObj != null) {
            mf.setFieldValue(entity,refObj);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 104814
Project: 104814
Buggy source:
private Object readMapOrCollectionOrEntity(DBObject dbObj,MappedField mf,EntityCache cache,Mapper mapr){
  if (Map.class.isAssignableFrom(mf.getSubClass()) || Iterable.class.isAssignableFrom(mf.getSubClass())) {
    MapOrCollectionMF mocMF=new MapOrCollectionMF((ParameterizedType)mf.getSubType());
    mapr.fromDb(dbObj,mocMF,cache);
    return mocMF.getValue();
  }
 else {
    Object newEntity=mapr.getOptions().objectFactory.createInstance(mf.getSubClass(),dbObj);
    return mapr.fromDb(dbObj,newEntity,cache);
  }
}

Fixed version (ground truth):
private Object readMapOrCollectionOrEntity(DBObject dbObj,MappedField mf,EntityCache cache,Mapper mapr){
  if (Map.class.isAssignableFrom(mf.getSubClass()) || Iterable.class.isAssignableFrom(mf.getSubClass())) {
    MapOrCollectionMF mocMF=new MapOrCollectionMF((ParameterizedType)mf.getSubType());
    mapr.fromDb(dbObj,mocMF,cache);
    return mocMF.getValue();
  }
 else {
    Object newEntity=mapr.getOptions().objectFactory.createInstance(mapr,mf,dbObj);
    return mapr.fromDb(dbObj,newEntity,cache);
  }
}
Program: 104816
Project: 104816
Buggy source:
private void readMap(final DBObject dbObject,final MappedField mf,final Object entity,final Reference refAnn,EntityCache cache,Mapper mapr){
  Class referenceObjClass=mf.getSubClass();
  Map map=mapr.getOptions().objectFactory.createMap(mf);
  BasicDBObject dbVal=(BasicDBObject)mf.getDbObjectValue(dbObject);
  if (dbVal != null) {
    if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
      map=mapr.proxyFactory.createMapProxy(map,referenceObjClass,refAnn.ignoreMissing(),mapr.datastoreProvider);
    }
    for (    Map.Entry<String,?> entry : dbVal.entrySet()) {
      DBRef dbRef=(DBRef)entry.getValue();
      if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
        ProxiedEntityReferenceMap proxiedMap=(ProxiedEntityReferenceMap)map;
        proxiedMap.__put(entry.getKey(),mapr.refToKey(dbRef));
      }
 else {
        Object resolvedObject=resolveObject(dbRef,referenceObjClass,refAnn.ignoreMissing(),mf,cache,mapr);
        map.put(entry.getKey(),resolvedObject);
      }
    }
  }
  mf.setFieldValue(entity,map);
}

Fixed version (ground truth):
private void readMap(final DBObject dbObject,final MappedField mf,final Object entity,final Reference refAnn,EntityCache cache,Mapper mapr){
  Class referenceObjClass=mf.getSubClass();
  Map map=mapr.getOptions().objectFactory.createMap(mf);
  BasicDBObject dbVal=(BasicDBObject)mf.getDbObjectValue(dbObject);
  if (dbVal != null) {
    if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
      map=mapr.proxyFactory.createMapProxy(map,referenceObjClass,refAnn.ignoreMissing(),mapr.datastoreProvider);
    }
    for (    Map.Entry<String,?> entry : dbVal.entrySet()) {
      DBRef dbRef=(DBRef)entry.getValue();
      if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
        ProxiedEntityReferenceMap proxiedMap=(ProxiedEntityReferenceMap)map;
        proxiedMap.__put(entry.getKey(),mapr.refToKey(dbRef));
      }
 else {
        Object resolvedObject=resolveObject(dbRef,mf,cache,mapr);
        map.put(entry.getKey(),resolvedObject);
      }
    }
  }
  mf.setFieldValue(entity,map);
}
Program: 104818
Project: 104818
Buggy source:
private void readSingle(final DBObject dbObject,final MappedField mf,final Object entity,Class fieldType,Reference refAnn,EntityCache cache,Mapper mapr){
  Class referenceObjClass=fieldType;
  DBRef dbRef=(DBRef)mf.getDbObjectValue(dbObject);
  if (dbRef != null) {
    Object resolvedObject=null;
    if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
      if (exists(referenceObjClass,dbRef,cache,mapr)) {
        resolvedObject=createOrReuseProxy(referenceObjClass,dbRef,cache,mapr);
      }
 else {
        if (!refAnn.ignoreMissing()) {
          throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
        }
      }
    }
 else {
      resolvedObject=resolveObject(dbRef,referenceObjClass,refAnn.ignoreMissing(),mf,cache,mapr);
    }
    mf.setFieldValue(entity,resolvedObject);
  }
}

Fixed version (ground truth):
private void readSingle(final DBObject dbObject,final MappedField mf,final Object entity,Class fieldType,Reference refAnn,EntityCache cache,Mapper mapr){
  Class referenceObjClass=fieldType;
  DBRef dbRef=(DBRef)mf.getDbObjectValue(dbObject);
  if (dbRef != null) {
    Object resolvedObject=null;
    if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
      if (exists(referenceObjClass,dbRef,cache,mapr)) {
        resolvedObject=createOrReuseProxy(referenceObjClass,dbRef,cache,mapr);
      }
 else {
        if (!refAnn.ignoreMissing()) {
          throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
        }
      }
    }
 else {
      resolvedObject=resolveObject(dbRef,mf,cache,mapr);
    }
    mf.setFieldValue(entity,resolvedObject);
  }
}
Program: 104819
Project: 104819
Buggy source:
Object resolveObject(final DBRef dbRef,final Class referenceObjClass,final boolean ignoreMissing,final MappedField mf,EntityCache cache,Mapper mapr){
  Key key=new Key(referenceObjClass,dbRef.getId());
  Object cached=cache.getEntity(key);
  if (cached != null)   return cached;
  BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
  if (refDbObject != null) {
    Object refObj=mapr.getOptions().objectFactory.createInstance(referenceObjClass,refDbObject);
    refObj=mapr.fromDb(refDbObject,refObj,cache);
    cache.putEntity(key,refObj);
    return refObj;
  }
  if (!ignoreMissing) {
    throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
Object resolveObject(final DBRef dbRef,final MappedField mf,EntityCache cache,Mapper mapr){
  Key key=new Key(mf.getSubClass(),dbRef.getId());
  Object cached=cache.getEntity(key);
  if (cached != null)   return cached;
  BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
  if (refDbObject != null) {
    Object refObj=mapr.getOptions().objectFactory.createInstance(mapr,mf,refDbObject);
    refObj=mapr.fromDb(refDbObject,refObj,cache);
    cache.putEntity(key,refObj);
    return refObj;
  }
  boolean ignoreMissing=mf.getAnnotation(Reference.class) != null && mf.getAnnotation(Reference.class).ignoreMissing();
  if (!ignoreMissing) {
    throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
  }
 else {
    return null;
  }
}
Program: 104820
Project: 104820
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){
  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) {
  }
  return 0;
}
Program: 104821
Project: 104821
Buggy source:
Object resolveObject(final DBRef dbRef,final MappedField mf,EntityCache cache,Mapper mapr){
  Key key=new Key(mf.getSubClass(),dbRef.getId());
  Object cached=cache.getEntity(key);
  if (cached != null)   return cached;
  BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
  if (refDbObject != null) {
    Object refObj=mapr.getOptions().objectFactory.createInstance(mapr,mf,refDbObject);
    refObj=mapr.fromDb(refDbObject,refObj,cache);
    cache.putEntity(key,refObj);
    return refObj;
  }
  boolean ignoreMissing=mf.getAnnotation(Reference.class) != null && mf.getAnnotation(Reference.class).ignoreMissing();
  if (!ignoreMissing) {
    throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
Object resolveObject(final DBRef dbRef,final MappedField mf,EntityCache cache,Mapper mapr){
  Key key=mapr.createKey(mf.isSingleValue() ? mf.getType() : mf.getSubClass(),dbRef.getId());
  Object cached=cache.getEntity(key);
  if (cached != null)   return cached;
  BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
  if (refDbObject != null) {
    Object refObj=mapr.getOptions().objectFactory.createInstance(mapr,mf,refDbObject);
    refObj=mapr.fromDb(refDbObject,refObj,cache);
    cache.putEntity(key,refObj);
    return refObj;
  }
  boolean ignoreMissing=mf.getAnnotation(Reference.class) != null && mf.getAnnotation(Reference.class).ignoreMissing();
  if (!ignoreMissing) {
    throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
  }
 else {
    return null;
  }
}
Program: 104822
Project: 104822
Buggy source:
public Mapper(MapperOptions opts){
  converters.setMapper(this);
  this.opts=opts;
}

Fixed version (ground truth):
public Mapper(MapperOptions opts){
  this();
  this.opts=opts;
}
Program: 104823
Project: 104823
Buggy source:
/** 
 * Converts a DBObject back to a type-safe java object (POJO)
 * @param entityClass The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
 */
public Object fromDBObject(final Class entityClass,final DBObject dbObject,EntityCache cache){
  if (dbObject == null) {
    Throwable t=new Throwable();
    logger.error("String_Node_Str",t);
    return null;
  }
  Object entity=null;
  entity=opts.objectFactory.createInstance(entityClass,dbObject);
  entity=fromDb(dbObject,entity,cache);
  return entity;
}

Fixed version (ground truth):
/** 
 * Converts a DBObject back to a type-safe java object (POJO)
 * @param entityClass The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
 */
public Object fromDBObject(final Class entityClass,final DBObject dbObject,EntityCache cache){
  if (dbObject == null) {
    Throwable t=new Throwable();
    log.error("String_Node_Str",t);
    return null;
  }
  Object entity=null;
  entity=opts.objectFactory.createInstance(entityClass,dbObject);
  entity=fromDb(dbObject,entity,cache);
  return entity;
}
Program: 104824
Project: 104824
Buggy source:
private void writeMappedField(BasicDBObject dbObject,MappedField mf,Object entity,Map<Object,DBObject> involvedObjects){
  Class<? extends Annotation> annType=null;
  if (mf.hasAnnotation(NotSaved.class))   return;
  for (  Class<? extends Annotation> testType : new Class[]{Property.class,Embedded.class,Serialized.class,Reference.class}) {
    if (mf.hasAnnotation(testType)) {
      annType=testType;
      break;
    }
  }
  if (Property.class.equals(annType) || Serialized.class.equals(annType) || mf.isTypeMongoCompatible()|| (converters.hasSimpleValueConverter(mf) || (converters.hasSimpleValueConverter(mf.getFieldValue(entity)))))   opts.valueMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
 else   if (Reference.class.equals(annType))   opts.referenceMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
 else   if (Embedded.class.equals(annType)) {
    opts.embeddedMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
  }
 else {
    logger.debug("String_Node_Str" + opts.defaultMapper + "String_Node_Str"+ mf);
    opts.defaultMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
  }
}

Fixed version (ground truth):
private void writeMappedField(BasicDBObject dbObject,MappedField mf,Object entity,Map<Object,DBObject> involvedObjects){
  Class<? extends Annotation> annType=null;
  if (mf.hasAnnotation(NotSaved.class))   return;
  for (  Class<? extends Annotation> testType : new Class[]{Property.class,Embedded.class,Serialized.class,Reference.class}) {
    if (mf.hasAnnotation(testType)) {
      annType=testType;
      break;
    }
  }
  if (Property.class.equals(annType) || Serialized.class.equals(annType) || mf.isTypeMongoCompatible()|| (converters.hasSimpleValueConverter(mf) || (converters.hasSimpleValueConverter(mf.getFieldValue(entity)))))   opts.valueMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
 else   if (Reference.class.equals(annType))   opts.referenceMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
 else   if (Embedded.class.equals(annType)) {
    opts.embeddedMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
  }
 else {
    log.debug("String_Node_Str" + opts.defaultMapper + "String_Node_Str"+ mf);
    opts.defaultMapper.toDBObject(entity,mf,dbObject,involvedObjects,this);
  }
}
Program: 104826
Project: 104826
Buggy source:
/** 
 * Converts a list of refs to keys 
 */
@SuppressWarnings("String_Node_Str") public static <T>List<Key<T>> refsToKeys(List<DBRef> refs,Class<T> c){
  ArrayList<Key<T>> keys=new ArrayList<Key<T>>(refs.size());
  for (  DBRef ref : refs) {
    keys.add(new Key(ref));
  }
  return keys;
}

Fixed version (ground truth):
/** 
 * Converts a list of refs to keys 
 */
public static <T>List<Key<T>> refsToKeys(List<DBRef> refs,Class<T> c){
  ArrayList<Key<T>> keys=new ArrayList<Key<T>>(refs.size());
  for (  DBRef ref : refs) {
    keys.add(new Key<T>(ref));
  }
  return keys;
}
Program: 104827
Project: 104827
Buggy source:
/** 
 * Queries the server to check for each DBRef 
 */
@SuppressWarnings("String_Node_Str") public <T>List<Key<T>> getKeysByRefs(List<DBRef> refs){
  ArrayList<Key<T>> tempKeys=new ArrayList<Key<T>>(refs.size());
  Map<String,List<DBRef>> kindMap=new HashMap<String,List<DBRef>>();
  for (  DBRef ref : refs) {
    if (kindMap.containsKey(ref.getRef()))     kindMap.get(ref.getRef()).add(ref);
 else     kindMap.put(ref.getRef(),new ArrayList<DBRef>(Collections.singletonList((DBRef)ref)));
  }
  for (  String kind : kindMap.keySet()) {
    List objIds=new ArrayList();
    List<DBRef> kindRefs=kindMap.get(kind);
    for (    DBRef key : kindRefs) {
      objIds.add(key.getId());
    }
    List<Key<T>> kindResults=this.<T>find(kind,null).disableValidation().filter("String_Node_Str",objIds).asKeyList();
    tempKeys.addAll(kindResults);
  }
  ArrayList<Key<T>> keys=new ArrayList<Key<T>>(refs.size());
  for (  DBRef ref : refs) {
    Key<T> testKey=new Key<T>(ref);
    if (tempKeys.contains(testKey))     keys.add(testKey);
  }
  return keys;
}

Fixed version (ground truth):
/** 
 * Queries the server to check for each DBRef 
 */
public <T>List<Key<T>> getKeysByRefs(List<DBRef> refs){
  ArrayList<Key<T>> tempKeys=new ArrayList<Key<T>>(refs.size());
  Map<String,List<DBRef>> kindMap=new HashMap<String,List<DBRef>>();
  for (  DBRef ref : refs) {
    if (kindMap.containsKey(ref.getRef()))     kindMap.get(ref.getRef()).add(ref);
 else     kindMap.put(ref.getRef(),new ArrayList<DBRef>(Collections.singletonList((DBRef)ref)));
  }
  for (  String kind : kindMap.keySet()) {
    List<Object> objIds=new ArrayList<Object>();
    List<DBRef> kindRefs=kindMap.get(kind);
    for (    DBRef key : kindRefs) {
      objIds.add(key.getId());
    }
    List<Key<T>> kindResults=this.<T>find(kind,null).disableValidation().filter("String_Node_Str",objIds).asKeyList();
    tempKeys.addAll(kindResults);
  }
  ArrayList<Key<T>> keys=new ArrayList<Key<T>>(refs.size());
  for (  DBRef ref : refs) {
    Key<T> testKey=new Key<T>(ref);
    if (tempKeys.contains(testKey))     keys.add(testKey);
  }
  return keys;
}
Program: 104828
Project: 104828
Buggy source:
@SuppressWarnings("String_Node_Str") public <T>List<T> getByKeys(Class<T> clazz,Iterable<Key<T>> keys){
  Map<String,List<Key>> kindMap=new HashMap<String,List<Key>>();
  List<T> entities=new ArrayList<T>();
  for (  Key<?> key : keys) {
    key.updateKind(getMapper());
    if (kindMap.containsKey(key.getKind()))     kindMap.get(key.getKind()).add(key);
 else     kindMap.put(key.getKind(),new ArrayList<Key>(Collections.singletonList((Key)key)));
  }
  for (  String kind : kindMap.keySet()) {
    List objIds=new ArrayList();
    List<Key> kindKeys=kindMap.get(kind);
    for (    Key key : kindKeys) {
      objIds.add(key.getId());
    }
    List kindResults=find(kind,null).disableValidation().filter("String_Node_Str",objIds).asList();
    entities.addAll(kindResults);
  }
  return entities;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public <T>List<T> getByKeys(Class<T> clazz,Iterable<Key<T>> keys){
  Map<String,List<Key>> kindMap=new HashMap<String,List<Key>>();
  List<T> entities=new ArrayList<T>();
  for (  Key<?> key : keys) {
    key.updateKind(getMapper());
    if (kindMap.containsKey(key.getKind()))     kindMap.get(key.getKind()).add(key);
 else     kindMap.put(key.getKind(),new ArrayList<Key>(Collections.singletonList((Key)key)));
  }
  for (  String kind : kindMap.keySet()) {
    List<Object> objIds=new ArrayList<Object>();
    List<Key> kindKeys=kindMap.get(kind);
    for (    Key key : kindKeys) {
      objIds.add(key.getId());
    }
    List kindResults=find(kind,null).disableValidation().filter("String_Node_Str",objIds).asList();
    entities.addAll(kindResults);
  }
  return entities;
}
Program: 104829
Project: 104829
Buggy source:
@Test public void testIndexes(){
  MappedClass mc=morphia.getMapper().getMappedClass(Ad2.class);
  this.morphia.map(Ad2.class);
  assertFalse(hasNamedIndex("String_Node_Str",db.getCollection(mc.getCollectionName()).getIndexInfo()));
  ds.ensureIndexes(Ad2.class);
  assertTrue(hasNamedIndex("String_Node_Str",db.getCollection(mc.getCollectionName()).getIndexInfo()));
}

Fixed version (ground truth):
@Test public void testIndexes(){
  MappedClass mc=this.morphia.getMapper().addMappedClass(Ad2.class);
  assertFalse(hasNamedIndex("String_Node_Str",db.getCollection(mc.getCollectionName()).getIndexInfo()));
  ds.ensureIndexes(Ad2.class);
  assertTrue(hasNamedIndex("String_Node_Str",db.getCollection(mc.getCollectionName()).getIndexInfo()));
}
Program: 104830
Project: 104830
Buggy source:
/** 
 * Ensures (creating if necessary) the indexes found during class mapping (using   {@code @Indexed)}
 */
<T>void ensureIndexes(Class<T> clazz);

Fixed version (ground truth):
/** 
 * Ensures (creating if necessary) the indexes found during class mapping (using   {@code @Indexed)}, possibly in the background
 */
<T>void ensureIndexes(Class<T> clazz,boolean background);
Program: 104831
Project: 104831
Buggy source:
public void ensureIndexes(){
  for (  MappedClass mc : mapr.getMappedClasses().values()) {
    ensureIndexes(mc);
  }
}

Fixed version (ground truth):
public void ensureIndexes(boolean background){
  for (  MappedClass mc : mapr.getMappedClasses().values()) {
    ensureIndexes(mc,background);
  }
}
Program: 104832
Project: 104832
Buggy source:
public <T>void ensureIndex(Class<T> type,IndexFieldDef... fields){
  ensureIndex(type,null,fields,false,false);
}

Fixed version (ground truth):
public <T>void ensureIndex(Class<T> type,boolean background,IndexFieldDef... fields){
  ensureIndex(type,null,fields,false,false,background);
}
Program: 104833
Project: 104833
Buggy source:
private void writeCollection(final MappedField mf,final BasicDBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Iterable 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 {
        DBObject dbObj=mapr.toDBObject(o,involvedObjects);
        if (mf.getSubType().equals(o.getClass()) && !(dbObj instanceof BasicDBList)) {
          dbObj.removeField(Mapper.CLASS_NAME_FIELDNAME);
        }
        values.add(dbObj);
      }
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties) {
      dbObject.put(name,values);
    }
  }
}

Fixed version (ground truth):
private void writeCollection(final MappedField mf,final BasicDBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Iterable 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 {
        DBObject dbObj=mapr.toDBObject(o,involvedObjects);
        if (!mf.getSubType().isInterface() && !Modifier.isAbstract(mf.getSubType().getModifiers()) && mf.getSubType().equals(o.getClass())&& !(dbObj instanceof BasicDBList)) {
          dbObj.removeField(Mapper.CLASS_NAME_FIELDNAME);
        }
        values.add(dbObj);
      }
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties) {
      dbObject.put(name,values);
    }
  }
}
Program: 104834
Project: 104834
Buggy source:
private void writeMap(final MappedField mf,final BasicDBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Map<String,Object> map=(Map<String,Object>)fieldValue;
  if (map != null) {
    BasicDBObject values=new BasicDBObject();
    for (    Map.Entry<String,Object> entry : map.entrySet()) {
      Object entryVal=entry.getValue();
      Object val;
      if (entryVal == null)       val=null;
 else       if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(entryVal.getClass()))       val=mapr.converters.encode(entryVal);
 else {
        val=mapr.toDBObject(entryVal,involvedObjects);
        if (mf.getSubType().equals(entryVal.getClass()) && !(val instanceof BasicDBList))         ((DBObject)val).removeField(Mapper.CLASS_NAME_FIELDNAME);
      }
      String strKey=mapr.converters.encode(entry.getKey()).toString();
      values.put(strKey,val);
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties)     dbObject.put(name,values);
  }
}

Fixed version (ground truth):
private void writeMap(final MappedField mf,final BasicDBObject dbObject,Map<Object,DBObject> involvedObjects,String name,Object fieldValue,Mapper mapr){
  Map<String,Object> map=(Map<String,Object>)fieldValue;
  if (map != null) {
    BasicDBObject values=new BasicDBObject();
    for (    Map.Entry<String,Object> entry : map.entrySet()) {
      Object entryVal=entry.getValue();
      Object val;
      if (entryVal == null)       val=null;
 else       if (mapr.converters.hasSimpleValueConverter(mf) || mapr.converters.hasSimpleValueConverter(entryVal.getClass()))       val=mapr.converters.encode(entryVal);
 else {
        val=mapr.toDBObject(entryVal,involvedObjects);
        if (!mf.getSubType().isInterface() && !Modifier.isAbstract(mf.getSubType().getModifiers()) && !(val instanceof BasicDBList)&& mf.getSubType().equals(entryVal.getClass()))         ((DBObject)val).removeField(Mapper.CLASS_NAME_FIELDNAME);
      }
      String strKey=mapr.converters.encode(entry.getKey()).toString();
      values.put(strKey,val);
    }
    if (values.size() > 0 || mapr.getOptions().storeEmpties)     dbObject.put(name,values);
  }
}
Program: 104836
Project: 104836
Buggy source:
public UpdateOperations<T> add(String fieldExpr,Object value,boolean addDups){
  if (value == null)   throw new QueryException("String_Node_Str");
  Object dbObj=mapr.toMongoObject(value);
  add((addDups) ? "String_Node_Str" : "String_Node_Str",fieldExpr,dbObj);
  return this;
}

Fixed version (ground truth):
public UpdateOperations<T> add(String fieldExpr,Object value,boolean addDups){
  if (value == null)   throw new QueryException("String_Node_Str");
  Object dbObj=mapr.toMongoObject(value,true);
  add((addDups) ? "String_Node_Str" : "String_Node_Str",fieldExpr,dbObj);
  return this;
}
Program: 104837
Project: 104837
Buggy source:
public UpdateOperations<T> set(String fieldExpr,Object value){
  if (value == null)   throw new QueryException("String_Node_Str");
  Object dbObj=mapr.toMongoObject(value);
  add("String_Node_Str",fieldExpr,dbObj);
  return this;
}

Fixed version (ground truth):
public UpdateOperations<T> set(String fieldExpr,Object value){
  if (value == null)   throw new QueryException("String_Node_Str");
  Object dbObj=mapr.toMongoObject(value,true);
  add("String_Node_Str",fieldExpr,dbObj);
  return this;
}
Program: 104838
Project: 104838
Buggy source:
public UpdateOperations<T> addAll(String fieldExpr,List<?> values,boolean addDups){
  if (values == null || values.isEmpty())   throw new QueryException("String_Node_Str");
  List<?> convertedValues=(List<?>)mapr.toMongoObject(values);
  if (addDups)   add("String_Node_Str",fieldExpr,convertedValues);
 else   add("String_Node_Str",fieldExpr,new BasicDBObject("String_Node_Str",convertedValues));
  return this;
}

Fixed version (ground truth):
public UpdateOperations<T> addAll(String fieldExpr,List<?> values,boolean addDups){
  if (values == null || values.isEmpty())   throw new QueryException("String_Node_Str");
  List<?> convertedValues=(List<?>)mapr.toMongoObject(values,true);
  if (addDups)   add("String_Node_Str",fieldExpr,convertedValues);
 else   add("String_Node_Str",fieldExpr,new BasicDBObject("String_Node_Str",convertedValues));
  return this;
}
Program: 104839
Project: 104839
Buggy source:
@Test @Ignore public void retainsClassName(){
  X x=new X();
  E1 e1=new E1();
  e1.foo="String_Node_Str";
  x.map.put("String_Node_Str",e1);
  E2 e2=new E2();
  e2.bar="String_Node_Str";
  x.map.put("String_Node_Str",e2);
  ds.save(x);
  Query<X> state_query=ds.createQuery(X.class);
  UpdateOperations<X> state_update=ds.createUpdateOperations(X.class);
  state_update.set("String_Node_Str",e2);
  ds.update(state_query,state_update);
  x=ds.find(X.class).get();
}

Fixed version (ground truth):
@Test public void retainsClassName(){
  X x=new X();
  E1 e1=new E1();
  e1.foo="String_Node_Str";
  x.map.put("String_Node_Str",e1);
  E2 e2=new E2();
  e2.bar="String_Node_Str";
  x.map.put("String_Node_Str",e2);
  ds.save(x);
  Query<X> state_query=ds.createQuery(X.class);
  UpdateOperations<X> state_update=ds.createUpdateOperations(X.class);
  state_update.set("String_Node_Str",e2);
  ds.update(state_query,state_update);
  x=ds.find(X.class).get();
}
Program: 104840
Project: 104840
Buggy source:
/** 
 * Converts a DBObject back to a type-safe java object (POJO)
 * @param entityClass The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
 */
public Object fromDBObject(final Class entityClass,final DBObject dbObject,EntityCache cache){
  if (dbObject == null) {
    Throwable t=new Throwable();
    logger.error("String_Node_Str",t);
    return null;
  }
  Object entity=null;
  entity=ReflectionUtils.createInstance(entityClass,dbObject);
  fromDb(dbObject,entity,cache);
  return entity;
}

Fixed version (ground truth):
/** 
 * Converts a DBObject back to a type-safe java object (POJO)
 * @param entityClass The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
 */
public Object fromDBObject(final Class entityClass,final DBObject dbObject,EntityCache cache){
  if (dbObject == null) {
    Throwable t=new Throwable();
    logger.error("String_Node_Str",t);
    return null;
  }
  Object entity=null;
  entity=ReflectionUtils.createInstance(entityClass,dbObject);
  entity=fromDb(dbObject,entity,cache);
  return entity;
}
Program: 104841
Project: 104841
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 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 KeyConverter());
  addConverter(new MapOfValuesConverter(this));
  addConverter(new IterableConverter(this));
  addConverter(new ClassConverter());
  addConverter(new ObjectIdConverter());
  addConverter(new PassthroughConverter());
}
Program: 104845
Project: 104845
Buggy source:
@Override public Object decode(Class targetClass,Object val,MappedField optionalExtraInfo) throws MappingException {
  Object dbValue=val;
  if (dbValue instanceof Boolean) {
    return (Boolean)val;
  }
  String sVal=val.toString();
  return Boolean.parseBoolean(sVal);
}

Fixed version (ground truth):
@Override public Object decode(Class targetClass,Object val,MappedField optionalExtraInfo) throws MappingException {
  if (val == null)   return null;
  if (val instanceof Boolean)   return (Boolean)val;
  String sVal=val.toString();
  return Boolean.parseBoolean(sVal);
}
Program: 104846
Project: 104846
Buggy source:
@Override public Object decode(Class targetClass,Object val,MappedField optionalExtraInfo) throws MappingException {
  if (val instanceof Number)   return ((Number)val).byteValue();
  String sVal=val.toString();
  return Byte.parseByte(sVal);
}

Fixed version (ground truth):
@Override public Object decode(Class targetClass,Object val,MappedField optionalExtraInfo) throws MappingException {
  if (val == null)   return null;
  if (val instanceof Number)   return ((Number)val).byteValue();
  String sVal=val.toString();
  return Byte.parseByte(sVal);
}
Program: 104847
Project: 104847
Buggy source:
@Override public Object decode(Class targetClass,Object fromDBObject,MappedField optionalExtraInfo) throws MappingException {
  return fromDBObject.toString().toCharArray();
}

Fixed version (ground truth):
@Override public Object decode(Class targetClass,Object fromDBObject,MappedField optionalExtraInfo) throws MappingException {
  if (fromDBObject == null)   return null;
  return fromDBObject.toString().toCharArray();
}
Program: 104848
Project: 104848
Buggy source:
@Override public Object decode(Class targetClass,Object fromDBObject,MappedField optionalExtraInfo) throws MappingException {
  return fromDBObject.toString().charAt(0);
}

Fixed version (ground truth):
@Override public Object decode(Class targetClass,Object fromDBObject,MappedField optionalExtraInfo) throws MappingException {
  if (fromDBObject == null)   return null;
  return fromDBObject.toString().charAt(0);
}