Program: 58762
Project: 58762
Buggy source:
private Integer cluster(ISet set,Integer iVAIdContent,Integer iVAIdStorage,EClustererType eClustererType){
  ArrayList<Integer> indexes=new ArrayList<Integer>();
  ArrayList<Integer> count=new ArrayList<Integer>();
  ArrayList<Integer> alExamples=new ArrayList<Integer>();
  DistanceFunction distFunc=null;
  if (eDistanceMeasure == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distFunc=new EuclideanDistance();
 else   if (eDistanceMeasure == 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 -1;
  }
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  int iPercentage=1;
  if (eClustererType == EClustererType.GENE_CLUSTERING) {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=contentVA.size();
    if (iNrCluster >= iNrElements)     return -1;
    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 -2;
      }
    }
  }
 else {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=storageVA.size();
    if (iNrCluster >= iNrElements)     return -1;
    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 -2;
      }
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(25 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  if (eClustererType == 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 -1;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(10,false));
  try {
    clusterer.buildClusterer(data);
  }
 catch (  Exception e) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return -1;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return -2;
  }
  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 -1;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return -2;
  }
  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 -2;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(80,false));
  ClusterHelper.sortClusters(set,iVAIdContent,iVAIdStorage,alExamples,eClustererType);
  IVirtualArray virualArray;
  if (eClustererType == 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);
      }
    }
  }
  Integer clusteredVAId=set.createStorageVA(indexes);
  set.setAlClusterSizes(count);
  set.setAlExamples(alExamples);
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(50 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  return clusteredVAId;
}

Fixed version (ground truth):
private Integer cluster(ISet set,Integer iVAIdContent,Integer iVAIdStorage,EClustererType eClustererType){
  ArrayList<Integer> indexes=new ArrayList<Integer>();
  ArrayList<Integer> count=new ArrayList<Integer>();
  ArrayList<Integer> alExamples=new ArrayList<Integer>();
  DistanceFunction distFunc=null;
  if (eDistanceMeasure == EDistanceMeasure.EUCLIDEAN_DISTANCE)   distFunc=new EuclideanDistance();
 else   if (eDistanceMeasure == 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 -1;
  }
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  IVirtualArray contentVA=set.getVA(iVAIdContent);
  IVirtualArray storageVA=set.getVA(iVAIdStorage);
  int iPercentage=1;
  if (eClustererType == EClustererType.GENE_CLUSTERING) {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=contentVA.size();
    if (iNrCluster >= iNrElements)     return -1;
    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 -2;
      }
    }
  }
 else {
    GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
    int iNrElements=storageVA.size();
    if (iNrCluster >= iNrElements)     return -1;
    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 -2;
      }
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(25 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  if (eClustererType == 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 -1;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(10,false));
  try {
    clusterer.buildClusterer(data);
  }
 catch (  Exception e) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return -1;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return -2;
  }
  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 -1;
  }
  processEvents();
  if (bClusteringCanceled) {
    GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
    return -2;
  }
  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 -2;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(80,false));
  ClusterHelper.sortClusters(set,iVAIdContent,iVAIdStorage,alExamples,eClustererType);
  IVirtualArray virualArray;
  if (eClustererType == 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);
      }
    }
  }
  Integer clusteredVAId=0;
  if (eClustererType == EClustererType.GENE_CLUSTERING)   clusteredVAId=set.createStorageVA(indexes);
 else   if (eClustererType == EClustererType.EXPERIMENTS_CLUSTERING)   clusteredVAId=set.createSetVA(indexes);
  set.setAlClusterSizes(count);
  set.setAlExamples(alExamples);
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(50 * iProgressBarMultiplier + iProgressBarOffsetValue,true));
  return clusteredVAId;
}