Program: 108035
Project: 108035
Buggy source:
/** 
 * This method optimizes the given data output with local recoding to improve its utility
 * @param handle
 * @throws IOException 
 */
public void optimize(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.checker.getInputBuffer())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Set<Class<?>> supportedModels=new HashSet<Class<?>>();
  supportedModels.add(KAnonymity.class);
  supportedModels.add(DistinctLDiversity.class);
  supportedModels.add(RecursiveCLDiversity.class);
  supportedModels.add(EntropyLDiversity.class);
  supportedModels.add(HierarchicalDistanceTCloseness.class);
  supportedModels.add(EqualDistanceTCloseness.class);
  supportedModels.add(Inclusion.class);
  for (  PrivacyCriterion c : config.getCriteria()) {
    if (!supportedModels.contains(c.getClass())) {
      throw new UnsupportedOperationException("String_Node_Str" + c.getClass().getSimpleName());
    }
  }
  RowSet rowset=RowSet.create(output.getNumRows());
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      rowset.add(row);
    }
  }
  ARXConfiguration config=this.config.getSubsetInstance(rowset);
  DataDefinition definition=this.definition.clone();
  DataManager manager=this.manager.getSubsetInstance(rowset);
  ARXAnonymizer anonymizer=new ARXAnonymizer();
  Result result=null;
  try {
    result=anonymizer.anonymize(manager,definition,config);
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str");
  }
  if (result.optimum == null) {
    return;
  }
  TransformedData data=result.checker.applyTransformation(result.optimum,output.getOutputBufferMicroaggregated().getDictionary());
  int newIndex=-1;
  int[][] oldGeneralized=output.getOutputBufferGeneralized().getArray();
  int[][] oldMicroaggregated=output.getOutputBufferMicroaggregated().getArray();
  int[][] newGeneralized=data.bufferGeneralized.getArray();
  int[][] newMicroaggregated=data.bufferMicroaggregated.getArray();
  for (int oldIndex=0; oldIndex < rowset.length(); oldIndex++) {
    if (rowset.contains(oldIndex)) {
      newIndex++;
      System.arraycopy(newGeneralized[newIndex],0,oldGeneralized[oldIndex],0,newGeneralized[newIndex].length);
      System.arraycopy(newMicroaggregated[newIndex],0,oldMicroaggregated[oldIndex],0,newMicroaggregated[newIndex].length);
    }
  }
}

Fixed version (ground truth):
/** 
 * This method optimizes the given data output with local recoding to improve its utility
 * @param handle
 * @throws IOException 
 */
public void optimize(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.checker.getInputBuffer())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Set<Class<?>> supportedModels=new HashSet<Class<?>>();
  supportedModels.add(KAnonymity.class);
  supportedModels.add(DistinctLDiversity.class);
  supportedModels.add(RecursiveCLDiversity.class);
  supportedModels.add(EntropyLDiversity.class);
  supportedModels.add(HierarchicalDistanceTCloseness.class);
  supportedModels.add(EqualDistanceTCloseness.class);
  supportedModels.add(Inclusion.class);
  for (  PrivacyCriterion c : config.getCriteria()) {
    if (!supportedModels.contains(c.getClass())) {
      throw new UnsupportedOperationException("String_Node_Str" + c.getClass().getSimpleName());
    }
  }
  RowSet rowset=RowSet.create(output.getNumRows());
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      rowset.add(row);
    }
  }
  ARXConfiguration config=this.config.getSubsetInstance(rowset);
  DataDefinition definition=this.definition.clone();
  DataManager manager=this.manager.getSubsetInstance(rowset);
  ARXAnonymizer anonymizer=new ARXAnonymizer();
  Result result=null;
  try {
    result=anonymizer.anonymize(manager,definition,config);
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str");
  }
  if (result.optimum == null) {
    return;
  }
  TransformedData data=result.checker.applyTransformation(result.optimum,output.getOutputBufferMicroaggregated().getDictionary());
  int newIndex=-1;
  int[][] oldGeneralized=output.getOutputBufferGeneralized().getArray();
  int[][] oldMicroaggregated=output.getOutputBufferMicroaggregated().getArray();
  int[][] newGeneralized=data.bufferGeneralized.getArray();
  int[][] newMicroaggregated=data.bufferMicroaggregated.getArray();
  for (int oldIndex=0; oldIndex < rowset.length(); oldIndex++) {
    if (rowset.contains(oldIndex)) {
      newIndex++;
      if (oldGeneralized != null && oldGeneralized.length != 0) {
        System.arraycopy(newGeneralized[newIndex],0,oldGeneralized[oldIndex],0,newGeneralized[newIndex].length);
      }
      if (oldMicroaggregated != null && oldMicroaggregated.length != 0) {
        System.arraycopy(newMicroaggregated[newIndex],0,oldMicroaggregated[oldIndex],0,newMicroaggregated[newIndex].length);
      }
    }
  }
}