Program: 198915
Project: 198915
Buggy source:
/** 
 * Reload the set of recent tasks 
 */
public SpaceNode reload(Context context,int preloadCount){
  RecentsConfiguration config=RecentsConfiguration.getInstance();
  Resources res=context.getResources();
  LinkedHashSet<Task> tasksToLoad=new LinkedHashSet<Task>();
  TaskStack stack=new TaskStack();
  SpaceNode root=new SpaceNode();
  root.setStack(stack);
  SystemServicesProxy ssp=mSystemServicesProxy;
  List<ActivityManager.RecentTaskInfo> tasks=getRecentTasks(ssp);
  int taskCount=tasks.size();
  for (int i=0; i < taskCount; i++) {
    ActivityManager.RecentTaskInfo t=tasks.get(i);
    ActivityInfo info=ssp.getActivityInfo(t.baseIntent.getComponent(),t.userId);
    if (info == null)     continue;
    ActivityManager.TaskDescription av=t.taskDescription;
    String activityLabel=null;
    Drawable activityIcon=null;
    int activityColor=config.taskBarViewDefaultBackgroundColor;
    if (av != null) {
      activityLabel=(av.getLabel() != null ? av.getLabel() : ssp.getActivityLabel(info));
      activityIcon=(av.getIcon() != null) ? ssp.getBadgedIcon(new BitmapDrawable(res,av.getIcon()),t.userId) : null;
      if (av.getPrimaryColor() != 0) {
        activityColor=av.getPrimaryColor();
      }
    }
 else {
      activityLabel=ssp.getActivityLabel(info);
    }
    boolean isForemostTask=(i == (taskCount - 1));
    Task task=new Task(t.persistentId,(t.id > -1),t.baseIntent,t.affiliatedTaskId,activityLabel,activityIcon,activityColor,t.userId,t.firstActiveTime,t.lastActiveTime,(i == (taskCount - 1)));
    if (i >= (taskCount - preloadCount)) {
      task.applicationIcon=mApplicationIconCache.getCheckLastActiveTime(task.key);
      if (task.applicationIcon == null) {
        if (isForemostTask) {
          task.applicationIcon=ssp.getActivityIcon(info,task.userId);
          if (task.applicationIcon == null) {
            task.applicationIcon=mDefaultApplicationIcon;
          }
          mApplicationIconCache.put(task.key,task.applicationIcon);
        }
 else {
          tasksToLoad.add(task);
        }
      }
      task.thumbnail=mThumbnailCache.getCheckLastActiveTime(task.key);
      if (task.thumbnail == null) {
        if (isForemostTask) {
          task.thumbnail=ssp.getTaskThumbnail(task.key.id);
          if (task.thumbnail != null) {
            task.thumbnail.setHasAlpha(false);
          }
 else {
            task.thumbnail=mDefaultThumbnail;
          }
          mThumbnailCache.put(task.key,task.thumbnail);
        }
 else {
          tasksToLoad.add(task);
        }
      }
    }
    stack.addTask(task);
  }
  stack.createAffiliatedGroupings();
  mLoader.start(context);
  for (  Task t : tasksToLoad) {
    mLoadQueue.addTask(t);
  }
  mPackageMonitor.setTasks(tasks);
  return root;
}

Fixed version (ground truth):
/** 
 * Reload the set of recent tasks 
 */
public SpaceNode reload(Context context,int preloadCount){
  RecentsConfiguration config=RecentsConfiguration.getInstance();
  Resources res=context.getResources();
  LinkedHashSet<Task> tasksToLoad=new LinkedHashSet<Task>();
  TaskStack stack=new TaskStack();
  SpaceNode root=new SpaceNode();
  root.setStack(stack);
  SystemServicesProxy ssp=mSystemServicesProxy;
  List<ActivityManager.RecentTaskInfo> tasks=getRecentTasks(ssp);
  int taskCount=tasks.size();
  for (int i=0; i < taskCount; i++) {
    ActivityManager.RecentTaskInfo t=tasks.get(i);
    ActivityInfo info=ssp.getActivityInfo(t.baseIntent.getComponent(),t.userId);
    if (info == null)     continue;
    ActivityManager.TaskDescription av=t.taskDescription;
    String activityLabel=null;
    Drawable activityIcon=mDefaultApplicationIcon;
    int activityColor=config.taskBarViewDefaultBackgroundColor;
    if (av != null) {
      activityLabel=(av.getLabel() != null ? av.getLabel() : ssp.getActivityLabel(info));
      activityIcon=(av.getIcon() != null) ? ssp.getBadgedIcon(new BitmapDrawable(res,av.getIcon()),t.userId) : null;
      if (av.getPrimaryColor() != 0) {
        activityColor=av.getPrimaryColor();
      }
    }
 else {
      activityLabel=ssp.getActivityLabel(info);
    }
    Task task=new Task(t.persistentId,(t.id > -1),t.baseIntent,t.affiliatedTaskId,activityLabel,activityIcon,activityColor,t.userId,t.firstActiveTime,t.lastActiveTime,(i == (taskCount - 1)));
    if (i >= (taskCount - preloadCount)) {
      task.applicationIcon=mApplicationIconCache.getAndInvalidateIfModified(task.key);
      if (task.applicationIcon == null) {
        task.applicationIcon=ssp.getActivityIcon(info,task.userId);
        if (task.applicationIcon != null) {
          mApplicationIconCache.put(task.key,task.applicationIcon);
        }
      }
      if (task.applicationIcon == null) {
        tasksToLoad.add(task);
      }
      task.thumbnail=mThumbnailCache.getAndInvalidateIfModified(task.key);
      if (task.thumbnail == null) {
        task.thumbnail=ssp.getTaskThumbnail(task.key.id);
        if (task.thumbnail != null) {
          task.thumbnail.setHasAlpha(false);
          mThumbnailCache.put(task.key,task.thumbnail);
        }
      }
      if (task.thumbnail == null) {
        tasksToLoad.add(task);
      }
    }
    stack.addTask(task);
  }
  stack.createAffiliatedGroupings();
  mLoader.start(context);
  mLoadQueue.addTasks(tasksToLoad);
  mPackageMonitor.setTasks(tasks);
  return root;
}