Program: 58842
Project: 58842
Buggy source:
/** 
 * Function responsible for handling SelectionDelta for embedded heatmap
 */
private void triggerSelectionBlock(){
  int iCount=iFirstSample;
  for (int i=0; i < iSelectorBar - 1; i++)   iCount+=iAlNumberSamples.get(i);
  List<SelectionCommand> commands=new ArrayList<SelectionCommand>();
  SelectionCommand command=new SelectionCommand(ESelectionCommandType.RESET);
  commands.add(command);
  glHeatMapView.handleContentTriggerSelectionCommand(eFieldDataType,commands);
  IVirtualArrayDelta delta=new VirtualArrayDelta(eFieldDataType);
  ISelectionDelta selectionDelta=new SelectionDelta(eFieldDataType);
  IVirtualArray currentVirtualArray=set.getVA(iContentVAID);
  int iIndex=0;
  int iContentIndex=0;
  for (int index=0; index < iSamplesPerHeatmap; index++) {
    iIndex=iCount + index;
    if (iIndex < currentVirtualArray.size()) {
      iContentIndex=currentVirtualArray.get(iIndex);
    }
    delta.add(VADeltaItem.append(iContentIndex));
    for (    HeatMapSelection selection : AlSelection) {
      if (selection.getContentIndex() == iContentIndex) {
        selectionDelta.addSelection(iContentIndex,selection.getSelectionType());
      }
    }
  }
  glHeatMapView.handleVirtualArrayUpdate(delta,getShortInfo());
  if (selectionDelta.size() > 0) {
    glHeatMapView.handleSelectionUpdate(selectionDelta,true,null);
  }
  commands=new ArrayList<SelectionCommand>();
  command=new SelectionCommand(ESelectionCommandType.RESET);
  commands.add(command);
  glHeatMapView.handleStorageTriggerSelectionCommand(eExperimentDataType,commands);
  IVirtualArrayDelta deltaExp=new VirtualArrayDelta(eExperimentDataType);
  ISelectionDelta selectionDeltaEx=new SelectionDelta(eExperimentDataType);
  IVirtualArray currentVirtualArrayEx=set.getVA(iStorageVAID);
  for (int index=0; index < currentVirtualArrayEx.size(); index++) {
    iContentIndex=currentVirtualArrayEx.get(index);
    deltaExp.add(VADeltaItem.append(iContentIndex));
    for (    Integer selection : AlExpMouseOver) {
      if (selection == iContentIndex) {
        selectionDeltaEx.addSelection(iContentIndex,ESelectionType.MOUSE_OVER);
      }
    }
    for (    Integer selection : AlExpSelected) {
      if (selection == iContentIndex) {
        selectionDeltaEx.addSelection(iContentIndex,ESelectionType.SELECTION);
      }
    }
  }
  glHeatMapView.handleVirtualArrayUpdate(deltaExp,getShortInfo());
  if (selectionDeltaEx.size() > 0) {
    glHeatMapView.handleSelectionUpdate(selectionDeltaEx,true,null);
  }
}

Fixed version (ground truth):
/** 
 * Function responsible for handling SelectionDelta for embedded heatmap
 */
private void triggerSelectionBlock(){
  int iCount=iFirstSample;
  for (int i=0; i < iSelectorBar - 1; i++)   iCount+=iAlNumberSamples.get(i);
  List<SelectionCommand> commands=new ArrayList<SelectionCommand>();
  glHeatMapView.handleContentTriggerSelectionCommand(eFieldDataType,commands);
  glHeatMapView.resetView();
  IVirtualArrayDelta delta=new VirtualArrayDelta(eFieldDataType);
  ISelectionDelta selectionDelta=new SelectionDelta(eFieldDataType);
  IVirtualArray currentVirtualArray=set.getVA(iContentVAID);
  int iIndex=0;
  int iContentIndex=0;
  for (int index=0; index < iSamplesPerHeatmap; index++) {
    iIndex=iCount + index;
    if (iIndex < currentVirtualArray.size()) {
      iContentIndex=currentVirtualArray.get(iIndex);
    }
    delta.add(VADeltaItem.append(iContentIndex));
    for (    HeatMapSelection selection : AlSelection) {
      if (selection.getContentIndex() == iContentIndex) {
        selectionDelta.addSelection(iContentIndex,selection.getSelectionType());
      }
    }
  }
  glHeatMapView.handleVirtualArrayUpdate(delta,getShortInfo());
  if (selectionDelta.size() > 0) {
    glHeatMapView.handleSelectionUpdate(selectionDelta,true,null);
  }
  commands=new ArrayList<SelectionCommand>();
  SelectionCommand command=new SelectionCommand(ESelectionCommandType.RESET);
  commands.add(command);
  glHeatMapView.handleStorageTriggerSelectionCommand(eExperimentDataType,commands);
  IVirtualArrayDelta deltaExp=new VirtualArrayDelta(eExperimentDataType);
  ISelectionDelta selectionDeltaEx=new SelectionDelta(eExperimentDataType);
  IVirtualArray currentVirtualArrayEx=set.getVA(iStorageVAID);
  for (int index=0; index < currentVirtualArrayEx.size(); index++) {
    iContentIndex=currentVirtualArrayEx.get(index);
    deltaExp.add(VADeltaItem.append(iContentIndex));
    for (    Integer selection : AlExpMouseOver) {
      if (selection == iContentIndex) {
        selectionDeltaEx.addSelection(iContentIndex,ESelectionType.MOUSE_OVER);
      }
    }
    for (    Integer selection : AlExpSelected) {
      if (selection == iContentIndex) {
        selectionDeltaEx.addSelection(iContentIndex,ESelectionType.SELECTION);
      }
    }
  }
  glHeatMapView.handleVirtualArrayUpdate(deltaExp,getShortInfo());
  if (selectionDeltaEx.size() > 0) {
    glHeatMapView.handleSelectionUpdate(selectionDeltaEx,true,null);
  }
}