Program: 61816
Project: 61816
Buggy source:
/** 
 * Removes an action from the action list, and updates all references
 * @param actions
 * @param index
 * @param version
 * @param removeWhenLast
 * @return
 */
public static boolean removeAction(List<Action> actions,int index,int version,boolean removeWhenLast){
  if (index < 0 || actions.size() <= index) {
    return false;
  }
  long startIp=actions.get(0).getAddress();
  Action lastAction=actions.get(actions.size() - 1);
  int lastIdx=(int)lastAction.getAddress();
  long endAddress=lastAction.getAddress() + getTotalActionLength(lastAction);
  List<Action> actionMap=new ArrayList<>(lastIdx);
  for (int i=0; i <= lastIdx; i++) {
    actionMap.add(null);
  }
  for (  Action a : actions) {
    actionMap.set((int)a.getAddress(),a);
  }
  Map<Action,List<Action>> containerLastActions=new HashMap<>();
  getContainerLastActions(actionMap,containerLastActions);
  Map<Action,Action> jumps=new HashMap<>();
  getJumps(actions,jumps);
  Action prevAction=index > 0 ? actions.get(index - 1) : null;
  Action nextAction=index + 1 < actions.size() ? actions.get(index + 1) : null;
  Action actionToRemove=actions.get(index);
  for (  Action a : containerLastActions.keySet()) {
    List<Action> lastActions=containerLastActions.get(a);
    for (int i=0; i < lastActions.size(); i++) {
      if (lastActions.get(i) == actionToRemove) {
        if (!removeWhenLast) {
          return false;
        }
        lastActions.set(i,prevAction);
      }
    }
  }
  for (  Action a : jumps.keySet()) {
    Action targetAction=jumps.get(a);
    if (targetAction == actionToRemove) {
      jumps.put(a,nextAction);
    }
  }
  if (containerLastActions.containsKey(actionToRemove)) {
    containerLastActions.remove(actionToRemove);
  }
  if (jumps.containsKey(actionToRemove)) {
    jumps.remove(actionToRemove);
  }
  actions.remove(index);
  updateAddresses(actions,startIp,version);
  updateJumps(actions,jumps,containerLastActions,endAddress,version);
  updateActionStores(actions,jumps);
  updateContainerSizes(actions,containerLastActions);
  updateActionLengths(actions,version);
  return true;
}

Fixed version (ground truth):
/** 
 * Removes an action from the action list, and updates all references
 * @param actions
 * @param index
 * @param version
 * @param removeWhenLast
 * @return
 */
public static boolean removeAction(List<Action> actions,int index,int version,boolean removeWhenLast){
  if (index < 0 || actions.size() <= index) {
    return false;
  }
  long startIp=actions.get(0).getAddress();
  Action lastAction=actions.get(actions.size() - 1);
  int lastIdx=(int)lastAction.getAddress();
  long endAddress=lastAction.getAddress() + getTotalActionLength(lastAction);
  List<Action> actionMap=new ArrayList<>(lastIdx);
  for (int i=0; i <= lastIdx; i++) {
    actionMap.add(null);
  }
  for (  Action a : actions) {
    actionMap.set((int)a.getAddress(),a);
  }
  Map<Action,List<Action>> containerLastActions=new HashMap<>();
  getContainerLastActions(actionMap,containerLastActions);
  Map<Action,Action> jumps=new HashMap<>();
  getJumps(actions,jumps);
  Action prevAction=index > 0 ? actions.get(index - 1) : null;
  Action nextAction=index + 1 < actions.size() ? actions.get(index + 1) : null;
  Action actionToRemove=actions.get(index);
  for (  Action a : containerLastActions.keySet()) {
    List<Action> lastActions=containerLastActions.get(a);
    for (int i=0; i < lastActions.size(); i++) {
      if (lastActions.get(i) == actionToRemove) {
        if (!removeWhenLast) {
          return false;
        }
        lastActions.set(i,prevAction);
      }
    }
  }
  for (  Action a : jumps.keySet()) {
    Action targetAction=jumps.get(a);
    if (targetAction == actionToRemove) {
      jumps.put(a,nextAction);
    }
  }
  if (containerLastActions.containsKey(actionToRemove)) {
    containerLastActions.remove(actionToRemove);
  }
  if (jumps.containsKey(actionToRemove)) {
    jumps.remove(actionToRemove);
  }
  actions.remove(index);
  updateAddresses(actions,startIp,version);
  updateJumps(actions,jumps,containerLastActions,endAddress,version);
  updateContainerSizes(actions,containerLastActions);
  updateActionLengths(actions,version);
  return true;
}