Program: 58715
Project: 58715
Buggy source:
private IVirtualArray cluster(ISet set,ClusterState clusterState){
  ArrayList<Integer> indexes=new ArrayList<Integer>();
  ArrayList<Integer> count=new ArrayList<Integer>();
  ArrayList<Integer> alExamples=new ArrayList<Integer>();
  DistanceFunction distFunc=null;
  if (clusterState.getDistanceMeasure() == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distFunc=new EuclideanDistance();
 else   if (clusterState.getDistanceMeasure() == EDistanceMeasure.MANHATTAHN_DISTANCE)   distFunc=new ManhattanDistance();
  try {
    clusterer.setNumClusters(iNrCluster);
    clusterer.setMaxIterations(1000);
    if (distFunc != null)     clusterer.setDistanceFunction(distFunc);
  }
 catch (  Exception e2) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  int iPercentage=1;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING) {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=contentVA.size();
    if (iNrCluster >= iNrElements)     return null;
    for (int nr=0; nr < storageVA.size(); nr++) {
      buffer.append("String_Node_Str" + nr + "String_Node_Str");
    }
    buffer.append("String_Node_Str");
    int icnt=0;
    for (    Integer iContentIndex : contentVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)icnt / contentVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,false));
          iPercentage++;
        }
        for (        Integer iStorageIndex : storageVA) {
          buffer.append(set.get(iStorageIndex).getFloat(EDataRepresentation.NORMALIZED,iContentIndex) + "String_Node_Str");
        }
        buffer.append("String_Node_Str");
        icnt++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
        return null;
      }
    }
  }
 else {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=storageVA.size();
    if (iNrCluster >= iNrElements)     return null;
    for (int nr=0; nr < contentVA.size(); nr++) {
      buffer.append("String_Node_Str" + nr + "String_Node_Str");
    }
    buffer.append("String_Node_Str");
    int isto=0;
    for (    Integer iStorageIndex : storageVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)isto / contentVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,false));
          iPercentage++;
        }
        for (        Integer iContentIndex : contentVA) {
          buffer.append(set.get(iStorageIndex).getFloat(EDataRepresentation.NORMALIZED,iContentIndex) + "String_Node_Str");
        }
        buffer.append("String_Node_Str");
        isto++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
        return null;
      }
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(25 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
 else   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
  Instances data=null;
  try {
    data=new Instances(new StringReader(buffer.toString()));
  }
 catch (  IOException e1) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(10,false));
  try {
    clusterer.buildClusterer(data);
  }
 catch (  Exception e) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(45,false));
  ClusterEvaluation eval=new ClusterEvaluation();
  eval.setClusterer(clusterer);
  try {
    eval.evaluateClusterer(data);
  }
 catch (  Exception e) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(60,false));
  double[] ClusterAssignments=eval.getClusterAssignments();
  for (int i=0; i < iNrCluster; i++) {
    count.add(0);
  }
  for (int j=0; j < iNrCluster; j++) {
    for (int i=0; i < data.numInstances(); i++) {
      if (ClusterAssignments[i] == j) {
        alExamples.add(i);
        break;
      }
    }
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(80,false));
  ClusterHelper.sortClusters(set,iVAIdContent,iVAIdStorage,alExamples,clusterState.getClustererType());
  IVirtualArray virualArray;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   virualArray=set.getVA(iVAIdContent);
 else   virualArray=set.getVA(iVAIdStorage);
  for (int cluster=0; cluster < iNrCluster; cluster++) {
    for (int i=0; i < data.numInstances(); i++) {
      if (ClusterAssignments[i] == cluster) {
        indexes.add(virualArray.get(i));
        count.set(cluster,count.get(cluster) + 1);
      }
    }
  }
  IVirtualArray virtualArray=null;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   virtualArray=new VirtualArray(EVAType.CONTENT,set.depth(),indexes);
 else   if (clusterState.getClustererType() == EClustererType.EXPERIMENTS_CLUSTERING)   virtualArray=new VirtualArray(EVAType.STORAGE,set.size(),indexes);
  set.setAlClusterSizes(count);
  set.setAlExamples(alExamples);
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(50 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  return virtualArray;
}

Fixed version (ground truth):
private IVirtualArray cluster(ISet set,ClusterState clusterState){
  ArrayList<Integer> indexes=new ArrayList<Integer>();
  ArrayList<Integer> count=new ArrayList<Integer>();
  ArrayList<Integer> alExamples=new ArrayList<Integer>();
  DistanceFunction distFunc=null;
  if (clusterState.getDistanceMeasure() == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distFunc=new EuclideanDistance();
 else   if (clusterState.getDistanceMeasure() == EDistanceMeasure.MANHATTAHN_DISTANCE)   distFunc=new ManhattanDistance();
  try {
    clusterer.setNumClusters(iNrCluster);
    clusterer.setMaxIterations(1000);
    if (distFunc != null)     clusterer.setDistanceFunction(distFunc);
  }
 catch (  Exception e2) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  int iPercentage=1;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING) {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=contentVA.size();
    if (iNrCluster >= iNrElements)     return null;
    for (int nr=0; nr < storageVA.size(); nr++) {
      buffer.append("String_Node_Str" + nr + "String_Node_Str");
    }
    buffer.append("String_Node_Str");
    int icnt=0;
    for (    Integer iContentIndex : contentVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)icnt / contentVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,false));
          iPercentage++;
        }
        for (        Integer iStorageIndex : storageVA) {
          buffer.append(set.get(iStorageIndex).getFloat(EDataRepresentation.NORMALIZED,iContentIndex) + "String_Node_Str");
        }
        buffer.append("String_Node_Str");
        icnt++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
        return null;
      }
    }
  }
 else {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=storageVA.size();
    if (iNrCluster >= iNrElements)     return null;
    for (int nr=0; nr < contentVA.size(); nr++) {
      buffer.append("String_Node_Str" + nr + "String_Node_Str");
    }
    buffer.append("String_Node_Str");
    int isto=0;
    for (    Integer iStorageIndex : storageVA) {
      if (bClusteringCanceled == false) {
        int tempPercentage=(int)((float)isto / contentVA.size() * 100);
        if (iPercentage == tempPercentage) {
          GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,false));
          iPercentage++;
        }
        for (        Integer iContentIndex : contentVA) {
          buffer.append(set.get(iStorageIndex).getFloat(EDataRepresentation.NORMALIZED,iContentIndex) + "String_Node_Str");
        }
        buffer.append("String_Node_Str");
        isto++;
        processEvents();
      }
 else {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
        return null;
      }
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(25 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
 else   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
  Instances data=null;
  try {
    data=new Instances(new StringReader(buffer.toString()));
  }
 catch (  IOException e1) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(10,false));
  try {
    clusterer.buildClusterer(data);
  }
 catch (  Exception e) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(45,false));
  ClusterEvaluation eval=new ClusterEvaluation();
  eval.setClusterer(clusterer);
  try {
    eval.evaluateClusterer(data);
  }
 catch (  Exception e) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(60,false));
  double[] ClusterAssignments=eval.getClusterAssignments();
  for (int i=0; i < iNrCluster; i++) {
    count.add(0);
  }
  IVirtualArray currentVA=null;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   currentVA=set.getVA(iVAIdContent);
 else   currentVA=set.getVA(iVAIdStorage);
  for (int cluster=0; cluster < iNrCluster; cluster++) {
    for (int i=0; i < data.numInstances(); i++) {
      if (ClusterAssignments[i] == cluster) {
        alExamples.add(currentVA.get(i));
        break;
      }
    }
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return null;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(80,false));
  IVirtualArray virualArray;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   virualArray=set.getVA(iVAIdContent);
 else   virualArray=set.getVA(iVAIdStorage);
  for (int cluster=0; cluster < iNrCluster; cluster++) {
    for (int i=0; i < data.numInstances(); i++) {
      if (ClusterAssignments[i] == cluster) {
        indexes.add(virualArray.get(i));
        count.set(cluster,count.get(cluster) + 1);
      }
    }
  }
  IVirtualArray virtualArray=null;
  if (clusterState.getClustererType() == EClustererType.GENE_CLUSTERING)   virtualArray=new VirtualArray(EVAType.CONTENT,set.depth(),indexes);
 else   if (clusterState.getClustererType() == EClustererType.EXPERIMENTS_CLUSTERING)   virtualArray=new VirtualArray(EVAType.STORAGE,set.size(),indexes);
  set.setAlClusterSizes(count);
  set.setAlExamples(alExamples);
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(50 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  return virtualArray;
}