Program: 58367
Project: 58367
Buggy source:
public void setHeatMapActive(int groupIndex,boolean addToNewSelectionType){
  if (activeHeatMapID == groupIndex)   return;
  int previouslyActiveHeatMapID=activeHeatMapID;
  activeHeatMapID=groupIndex;
  if (previouslyActiveHeatMapID != -1) {
    GLHeatMap heatMap=hashHeatMaps.get(activeHeatMapID);
    ContentSelectionManager hmContentSelectionManager=heatMap.getContentSelectionManager();
    for (    Integer elementID : heatMap.getContentVA()) {
      hmContentSelectionManager.removeFromType(activeHeatMapSelectionType,elementID);
    }
    SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
  GLHeatMap heatMap=hashHeatMaps.get(groupIndex);
  ContentSelectionManager hmContentSelectionManager=heatMap.getContentSelectionManager();
  hmContentSelectionManager.addToType(activeHeatMapSelectionType,heatMap.getContentVA().getVirtualArray());
  SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
  selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
  eventPublisher.triggerEvent(selectionUpdateEvent);
  if (addToNewSelectionType) {
    SelectionType selectionType=new SelectionType();
    selectionType.setType(SELECTION_TYPE_NAME + selectionTypeNumber++);
    selectionType.setPriority(0.8f + 0.0001f * selectionTypeNumber);
    selectionType.setColor(ColorUtil.getColor(selectionTypeNumber));
    SelectionTypeEvent event=new SelectionTypeEvent();
    event.addSelectionType(selectionType);
    eventPublisher.triggerEvent(event);
    hmContentSelectionManager.addToType(selectionType,heatMap.getContentVA().getVirtualArray());
    selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
}

Fixed version (ground truth):
public void setHeatMapActive(int groupIndex,boolean addToNewSelectionType){
  if (activeHeatMapID == groupIndex)   return;
  int previouslyActiveHeatMapID=activeHeatMapID;
  activeHeatMapID=groupIndex;
  if (previouslyActiveHeatMapID != -1) {
    GLHeatMap heatMap=hashHeatMaps.get(activeHeatMapID);
    ContentSelectionManager hmContentSelectionManager=heatMap.getContentSelectionManager();
    for (    Integer elementID : heatMap.getContentVA()) {
      hmContentSelectionManager.removeFromType(activeHeatMapSelectionType,elementID);
    }
    SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
  GLHeatMap heatMap=hashHeatMaps.get(groupIndex);
  ContentSelectionManager hmContentSelectionManager=heatMap.getContentSelectionManager();
  hmContentSelectionManager.addToType(activeHeatMapSelectionType,heatMap.getContentVA().getVirtualArray());
  SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
  selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
  eventPublisher.triggerEvent(selectionUpdateEvent);
  if (addToNewSelectionType) {
    SelectionType selectionType=new SelectionType();
    selectionType.setType(SELECTION_TYPE_NAME + selectionTypeNumber);
    selectionType.setPriority(0.8f + 0.0001f * selectionTypeNumber);
    selectionType.setColor(ColorUtil.getColor(selectionTypeNumber++));
    selectionType.setManaged(true);
    SelectionTypeEvent event=new SelectionTypeEvent();
    event.addSelectionType(selectionType);
    eventPublisher.triggerEvent(event);
    hmContentSelectionManager.addToType(selectionType,heatMap.getContentVA().getVirtualArray());
    selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
}