Program: 193137
Project: 193137
Buggy source:
/** 
 * Sets a few tasks in one go, without calling any callbacks.
 * @param tasks the new set of tasks to replace the current set.
 * @param notifyStackChanges whether or not to callback on specific changes to the list of tasks.
 */
public void setTasks(List<Task> tasks,boolean notifyStackChanges){
  HashMap<Task.TaskKey,Task> currentTasksMap=createTaskKeyMapFromList(mRawTaskList);
  HashMap<Task.TaskKey,Task> newTasksMap=createTaskKeyMapFromList(tasks);
  ArrayList<Task> newTasks=new ArrayList<>();
  if (mCb == null) {
    notifyStackChanges=false;
  }
  int taskCount=mRawTaskList.size();
  for (int i=0; i < taskCount; i++) {
    Task task=mRawTaskList.get(i);
    if (!newTasksMap.containsKey(task.key)) {
      if (notifyStackChanges) {
        mCb.onStackTaskRemoved(this,task,i == (taskCount - 1),null);
      }
    }
 else {
      newTasks.add(task);
    }
  }
  taskCount=tasks.size();
  for (int i=0; i < taskCount; i++) {
    Task task=tasks.get(i);
    if (!currentTasksMap.containsKey(task.key)) {
      if (notifyStackChanges) {
        mCb.onStackTaskAdded(this,task);
      }
      newTasks.add(task);
    }
 else {
      newTasks.add(currentTasksMap.get(task.key));
    }
  }
  Collections.sort(newTasks,LAST_ACTIVE_TIME_COMPARATOR);
  ArrayList<Task> stackTasks=new ArrayList<>();
  ArrayList<Task> historyTasks=new ArrayList<>();
  int newTaskCount=newTasks.size();
  for (int i=0; i < newTaskCount; i++) {
    Task task=newTasks.get(i);
    if (task.isHistorical) {
      historyTasks.add(task);
    }
 else {
      stackTasks.add(task);
    }
  }
  mStackTaskList.set(stackTasks);
  mHistoryTaskList.set(historyTasks);
  mRawTaskList.clear();
  mRawTaskList.addAll(newTasks);
}

Fixed version (ground truth):
/** 
 * Sets a few tasks in one go, without calling any callbacks.
 * @param tasks the new set of tasks to replace the current set.
 * @param notifyStackChanges whether or not to callback on specific changes to the list of tasks.
 */
public void setTasks(List<Task> tasks,boolean notifyStackChanges){
  HashMap<Task.TaskKey,Task> currentTasksMap=createTaskKeyMapFromList(mRawTaskList);
  HashMap<Task.TaskKey,Task> newTasksMap=createTaskKeyMapFromList(tasks);
  ArrayList<Task> newTasks=new ArrayList<>();
  if (mCb == null) {
    notifyStackChanges=false;
  }
  int taskCount=mRawTaskList.size();
  for (int i=0; i < taskCount; i++) {
    Task task=mRawTaskList.get(i);
    if (!newTasksMap.containsKey(task.key)) {
      if (notifyStackChanges) {
        mCb.onStackTaskRemoved(this,task,i == (taskCount - 1),null);
      }
    }
    task.setGroup(null);
  }
  taskCount=tasks.size();
  for (int i=0; i < taskCount; i++) {
    Task task=tasks.get(i);
    if (!currentTasksMap.containsKey(task.key)) {
      if (notifyStackChanges) {
        mCb.onStackTaskAdded(this,task);
      }
      newTasks.add(task);
    }
 else {
      newTasks.add(currentTasksMap.get(task.key));
    }
  }
  Collections.sort(newTasks,LAST_ACTIVE_TIME_COMPARATOR);
  ArrayList<Task> stackTasks=new ArrayList<>();
  ArrayList<Task> historyTasks=new ArrayList<>();
  int newTaskCount=newTasks.size();
  for (int i=0; i < newTaskCount; i++) {
    Task task=newTasks.get(i);
    if (task.isHistorical) {
      historyTasks.add(task);
    }
 else {
      stackTasks.add(task);
    }
  }
  mStackTaskList.set(stackTasks);
  mHistoryTaskList.set(historyTasks);
  mRawTaskList.clear();
  mRawTaskList.addAll(newTasks);
  mGroups.clear();
  mAffinitiesGroups.clear();
}