Program: 104825
Project: 104825
Buggy source:
public Object toMongoObject(final Object javaObj,boolean includeClassName){
  if (javaObj == null) {
    return null;
  }
  Class origClass=javaObj.getClass();
  Object newObj=converters.encode(origClass,javaObj);
  if (newObj == null) {
    logger.warning("String_Node_Str" + javaObj + "String_Node_Str");
    return newObj;
  }
  Class type=newObj.getClass();
  boolean bSameType=origClass.equals(type);
  if (!bSameType && !(Map.class.isAssignableFrom(type) || Iterable.class.isAssignableFrom(type)))   return newObj;
 else {
    boolean isSingleValue=true;
    boolean isMap=false;
    Class subType=null;
    if (type.isArray() || Map.class.isAssignableFrom(type) || Iterable.class.isAssignableFrom(type)) {
      isSingleValue=false;
      isMap=ReflectionUtils.implementsInterface(type,Map.class);
      subType=(type.isArray()) ? type.getComponentType() : ReflectionUtils.getParameterizedClass(type,(isMap) ? 1 : 0);
    }
    if (isSingleValue && !ReflectionUtils.isPropertyType(type)) {
      DBObject dbObj=toDBObject(newObj);
      if (!includeClassName)       dbObj.removeField(CLASS_NAME_FIELDNAME);
      return dbObj;
    }
 else     if (newObj instanceof DBObject) {
      return newObj;
    }
 else     if (isMap) {
      if (ReflectionUtils.isPropertyType(subType))       return toDBObject(newObj);
 else {
        HashMap m=new HashMap();
        for (        Map.Entry e : (Iterable<Map.Entry>)((Map)newObj).entrySet())         m.put(e.getKey(),toMongoObject(e.getValue(),includeClassName));
        return m;
      }
    }
 else     if (!isSingleValue && !ReflectionUtils.isPropertyType(subType)) {
      ArrayList<Object> vals=new ArrayList<Object>();
      if (type.isArray())       for (      Object obj : (Object[])newObj)       vals.add(toMongoObject(obj,includeClassName));
 else       for (      Object obj : (Iterable)newObj)       vals.add(toMongoObject(obj,includeClassName));
      return vals;
    }
 else {
      return newObj;
    }
  }
}

Fixed version (ground truth):
public Object toMongoObject(final Object javaObj,boolean includeClassName){
  if (javaObj == null) {
    return null;
  }
  Class origClass=javaObj.getClass();
  Object newObj=converters.encode(origClass,javaObj);
  if (newObj == null) {
    log.warning("String_Node_Str" + javaObj + "String_Node_Str");
    return newObj;
  }
  Class type=newObj.getClass();
  boolean bSameType=origClass.equals(type);
  if (!bSameType && !(Map.class.isAssignableFrom(type) || Iterable.class.isAssignableFrom(type)))   return newObj;
 else {
    boolean isSingleValue=true;
    boolean isMap=false;
    Class subType=null;
    if (type.isArray() || Map.class.isAssignableFrom(type) || Iterable.class.isAssignableFrom(type)) {
      isSingleValue=false;
      isMap=ReflectionUtils.implementsInterface(type,Map.class);
      subType=(type.isArray()) ? type.getComponentType() : ReflectionUtils.getParameterizedClass(type,(isMap) ? 1 : 0);
    }
    if (isSingleValue && !ReflectionUtils.isPropertyType(type)) {
      DBObject dbObj=toDBObject(newObj);
      if (!includeClassName)       dbObj.removeField(CLASS_NAME_FIELDNAME);
      return dbObj;
    }
 else     if (newObj instanceof DBObject) {
      return newObj;
    }
 else     if (isMap) {
      if (ReflectionUtils.isPropertyType(subType))       return toDBObject(newObj);
 else {
        HashMap m=new HashMap();
        for (        Map.Entry e : (Iterable<Map.Entry>)((Map)newObj).entrySet())         m.put(e.getKey(),toMongoObject(e.getValue(),includeClassName));
        return m;
      }
    }
 else     if (!isSingleValue && !ReflectionUtils.isPropertyType(subType)) {
      ArrayList<Object> vals=new ArrayList<Object>();
      if (type.isArray())       for (      Object obj : (Object[])newObj)       vals.add(toMongoObject(obj,includeClassName));
 else       for (      Object obj : (Iterable)newObj)       vals.add(toMongoObject(obj,includeClassName));
      return vals;
    }
 else {
      return newObj;
    }
  }
}