Program: 57464
Project: 57464
Buggy source:
public void handlePathwayElementSelection(SelectionType selectionType,int externalID){
  if (externalID == -1) {
    if (isPathStartSelected && selectionType == SelectionType.SELECTION && allPaths != null && allPaths.size() > 0)     isPathStartSelected=false;
  }
 else {
    setDisplayListDirty();
    PathwayVertexRep previouslySelectedVertexRep=null;
    if (geneSelectionManager.getElements(SelectionType.SELECTION).size() == 1) {
      previouslySelectedVertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep((Integer)geneSelectionManager.getElements(SelectionType.SELECTION).toArray()[0]);
    }
    geneSelectionManager.clearSelection(selectionType);
    if (metaboliteSelectionManager.getNumberOfElements(selectionType) > 0) {
      metaboliteSelectionManager.clearSelection(selectionType);
      metaboliteSelectionManager.triggerSelectionUpdateEvent();
    }
    PathwayVertexRep vertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep(externalID);
    if (vertexRep.getType() == EPathwayVertexType.compound) {
      metaboliteSelectionManager.addToType(selectionType,vertexRep.getName().hashCode());
      metaboliteSelectionManager.triggerSelectionUpdateEvent();
    }
    if (isPathSelectionMode) {
      if (isPathStartSelected) {
        if (selectionType == SelectionType.SELECTION && (allPaths != null && allPaths.size() > 0)) {
          isPathStartSelected=false;
        }
        KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,previouslySelectedVertexRep,MAX_PATHS);
        if (vertexRep != previouslySelectedVertexRep) {
          allPaths=pathAlgo.getPaths(vertexRep);
        }
        if (allPaths != null && allPaths.size() > 0) {
          if (allPaths.size() <= selectedPathID)           selectedPathID=0;
          selectedPath=allPaths.get(selectedPathID);
          triggerPathUpdate();
          isBubbleTextureDirty=true;
        }
      }
 else {
        if (isShiftKeyDown) {
          if (selectedPathID < allPaths.size()) {
            selectedPath=allPaths.get(selectedPathID);
            isPathStartSelected=true;
          }
        }
 else {
          if (selectionType == SelectionType.SELECTION && vertexRep != null) {
            System.out.println("String_Node_Str");
            isPathStartSelected=true;
          }
        }
      }
    }
    geneSelectionManager.addToType(selectionType,vertexRep.getID());
    int iConnectionID=generalManager.getIDCreator().createID(ManagedObjectType.CONNECTION);
    geneSelectionManager.addConnectionID(iConnectionID,vertexRep.getID());
    connectedElementRepresentationManager.clear(geneSelectionManager.getIDType(),selectionType);
    createConnectionLines(selectionType,iConnectionID);
    SelectionDelta selectionDelta=createExternalSelectionDelta(geneSelectionManager.getDelta());
    SelectionUpdateEvent event=new SelectionUpdateEvent();
    event.setSender(this);
    event.setDataDomainID(dataDomain.getDataDomainID());
    event.setSelectionDelta((SelectionDelta)selectionDelta);
    eventPublisher.triggerEvent(event);
  }
}

Fixed version (ground truth):
public void handlePathwayElementSelection(SelectionType selectionType,int externalID){
  if (externalID == -1) {
    if (isPathStartSelected && selectionType == SelectionType.SELECTION && allPaths != null && allPaths.size() > 0)     isPathStartSelected=false;
  }
 else {
    setDisplayListDirty();
    PathwayVertexRep previouslySelectedVertexRep=null;
    if (geneSelectionManager.getElements(SelectionType.SELECTION).size() == 1) {
      previouslySelectedVertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep((Integer)geneSelectionManager.getElements(SelectionType.SELECTION).toArray()[0]);
    }
    geneSelectionManager.clearSelection(selectionType);
    if (metaboliteSelectionManager.getNumberOfElements(selectionType) > 0) {
      metaboliteSelectionManager.clearSelection(selectionType);
      metaboliteSelectionManager.triggerSelectionUpdateEvent();
    }
    PathwayVertexRep vertexRep=(PathwayVertexRep)pathwayItemManager.getPathwayVertexRep(externalID);
    if (vertexRep.getType() == EPathwayVertexType.compound) {
      metaboliteSelectionManager.addToType(selectionType,vertexRep.getName().hashCode());
      metaboliteSelectionManager.triggerSelectionUpdateEvent();
    }
    if (isPathSelectionMode) {
      if (isPathStartSelected) {
        if (selectionType == SelectionType.SELECTION && (allPaths != null && allPaths.size() > 0)) {
          isPathStartSelected=false;
        }
        if (previouslySelectedVertexRep == null)         return;
        KShortestPaths<PathwayVertexRep,DefaultEdge> pathAlgo=new KShortestPaths<PathwayVertexRep,DefaultEdge>(pathway,previouslySelectedVertexRep,MAX_PATHS);
        if (vertexRep != previouslySelectedVertexRep) {
          allPaths=pathAlgo.getPaths(vertexRep);
        }
        if (allPaths != null && allPaths.size() > 0) {
          if (allPaths.size() <= selectedPathID)           selectedPathID=0;
          selectedPath=allPaths.get(selectedPathID);
          triggerPathUpdate();
          isBubbleTextureDirty=true;
        }
      }
 else {
        if (isShiftKeyDown) {
          if (selectedPathID < allPaths.size()) {
            selectedPath=allPaths.get(selectedPathID);
            isPathStartSelected=true;
          }
        }
 else {
          if (selectionType == SelectionType.SELECTION && vertexRep != null) {
            System.out.println("String_Node_Str");
            isPathStartSelected=true;
          }
        }
      }
    }
    geneSelectionManager.addToType(selectionType,vertexRep.getID());
    int iConnectionID=generalManager.getIDCreator().createID(ManagedObjectType.CONNECTION);
    geneSelectionManager.addConnectionID(iConnectionID,vertexRep.getID());
    connectedElementRepresentationManager.clear(geneSelectionManager.getIDType(),selectionType);
    createConnectionLines(selectionType,iConnectionID);
    SelectionDelta selectionDelta=createExternalSelectionDelta(geneSelectionManager.getDelta());
    SelectionUpdateEvent event=new SelectionUpdateEvent();
    event.setSender(this);
    event.setDataDomainID(dataDomain.getDataDomainID());
    event.setSelectionDelta((SelectionDelta)selectionDelta);
    eventPublisher.triggerEvent(event);
  }
}