Program: 58759
Project: 58759
Buggy source:
public 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>();
  try {
    clusterer.setNumClusters(iNrCluster);
    clusterer.setMaxIterations(1000);
  }
 catch (  Exception e2) {
    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) {
    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,true));
          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       return -1;
    }
  }
 else {
    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,true));
          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       return -1;
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
  Instances data=null;
  try {
    data=new Instances(new StringReader(buffer.toString()));
  }
 catch (  IOException e1) {
    return -1;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(10,false));
  try {
    clusterer.buildClusterer(data);
  }
 catch (  Exception e) {
    return -1;
  }
  processEvents();
  if (bClusteringCanceled)   return -1;
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(45,false));
  ClusterEvaluation eval=new ClusterEvaluation();
  eval.setClusterer(clusterer);
  try {
    eval.evaluateClusterer(data);
  }
 catch (  Exception e) {
    return -1;
  }
  processEvents();
  if (bClusteringCanceled)   return -1;
  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)   return -1;
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(80,false));
  ClusterHelper.sortClusters(set,iVAIdContent,iVAIdStorage,alExamples,eClustererType);
  for (int cluster=0; cluster < iNrCluster; cluster++) {
    for (int i=0; i < data.numInstances(); i++) {
      if (ClusterAssignments[i] == cluster) {
        indexes.add(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(100,false));
  return clusteredVAId;
}

Fixed version (ground truth):
public 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>();
  try {
    clusterer.setNumClusters(iNrCluster);
    clusterer.setMaxIterations(1000);
  }
 catch (  Exception e2) {
    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) {
    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,true));
          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       return -1;
    }
  }
 else {
    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,true));
          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       return -1;
    }
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
  Instances data=null;
  try {
    data=new Instances(new StringReader(buffer.toString()));
  }
 catch (  IOException e1) {
    return -1;
  }
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(10,false));
  try {
    clusterer.buildClusterer(data);
  }
 catch (  Exception e) {
    return -1;
  }
  processEvents();
  if (bClusteringCanceled)   return -1;
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(45,false));
  ClusterEvaluation eval=new ClusterEvaluation();
  eval.setClusterer(clusterer);
  try {
    eval.evaluateClusterer(data);
  }
 catch (  Exception e) {
    return -1;
  }
  processEvents();
  if (bClusteringCanceled)   return -1;
  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)   return -1;
  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(100,false));
  return clusteredVAId;
}