Program: 58346
Project: 58346
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(ACompareViewState.ACTIVE_HEATMAP_SELECTION_TYPE,elementID);
    }
    SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
    selectionUpdateEvent.setSender(heatMap);
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
  GLHeatMap heatMap=hashHeatMaps.get(groupIndex);
  ContentSelectionManager hmContentSelectionManager=heatMap.getContentSelectionManager();
  hmContentSelectionManager.addToType(ACompareViewState.ACTIVE_HEATMAP_SELECTION_TYPE,heatMap.getContentVA().getVirtualArray());
  SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
  selectionUpdateEvent.setSelectionDelta(hmContentSelectionManager.getDelta());
  selectionUpdateEvent.setSender(heatMap);
  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);
    event.setSender(heatMap);
    eventPublisher.triggerEvent(event);
    hmContentSelectionManager.addToType(selectionType,heatMap.getContentVA().getVirtualArray());
    selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSender(heatMap);
    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);
    for (    Integer elementID : heatMap.getContentVA()) {
      contentSelectionManager.removeFromType(ACompareViewState.ACTIVE_HEATMAP_SELECTION_TYPE,elementID);
    }
    SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSelectionDelta(contentSelectionManager.getDelta());
    selectionUpdateEvent.setSender(heatMap);
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
  GLHeatMap heatMap=hashHeatMaps.get(groupIndex);
  contentSelectionManager.addToType(ACompareViewState.ACTIVE_HEATMAP_SELECTION_TYPE,heatMap.getContentVA().getVirtualArray());
  SelectionUpdateEvent selectionUpdateEvent=new SelectionUpdateEvent();
  selectionUpdateEvent.setSelectionDelta(contentSelectionManager.getDelta());
  selectionUpdateEvent.setSender(heatMap);
  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);
    event.setSender(heatMap);
    eventPublisher.triggerEvent(event);
    contentSelectionManager.addToType(selectionType,heatMap.getContentVA().getVirtualArray());
    selectionUpdateEvent=new SelectionUpdateEvent();
    selectionUpdateEvent.setSender(heatMap);
    selectionUpdateEvent.setSelectionDelta(contentSelectionManager.getDelta());
    eventPublisher.triggerEvent(selectionUpdateEvent);
  }
}