Program: 107793
Project: 107793
Buggy source:
/** 
 * This method optimizes the given data output with local recoding to improve its utility
 * @param handle
 * @param records A fraction [0,1] of records that need to be optimized.
 * @param gsFactor A factor [0,1] weighting generalization and suppression.The default value is 0.5, which means that generalization and suppression will be treated equally. A factor of 0 will favor suppression, and a factor of 1 will favor generalization. The values in between can be used for balancing both methods.
 * @param listener 
 * @return The number of optimized records
 */
public ARXProcessStatistics optimizeFast(DataHandle handle,double records,double gsFactor,ARXListener listener) throws RollbackRequiredException {
  if (listener == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (handle == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (!Double.isNaN(records) && (records <= 0d || records > 1d)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!Double.isNaN(gsFactor) && (gsFactor < 0d || gsFactor > 1d)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!(handle instanceof DataHandleOutput)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!isOptimizable(handle)) {
    return new ARXProcessStatistics();
  }
  long time=System.currentTimeMillis();
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized().getArray())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int initialRecords=0;
  RowSet rowset=RowSet.create(output.getNumRows());
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      rowset.add(row);
      initialRecords++;
    }
  }
  initialRecords=output.getNumRows() - initialRecords;
  ARXConfiguration config=this.config.getInstanceForLocalRecoding(rowset,gsFactor);
  if (!Double.isNaN(records)) {
    double absoluteRecords=records * handle.getNumRows();
    double relativeRecords=absoluteRecords / (double)rowset.size();
    relativeRecords=relativeRecords < 0d ? 0d : relativeRecords;
    relativeRecords=relativeRecords > 1d ? 1d : relativeRecords;
    config.setSuppressionLimit(1d - relativeRecords);
  }
  DataDefinition definition=this.definition.clone();
  DataManager manager=this.manager.getSubsetInstance(rowset);
  ARXAnonymizer anonymizer=new ARXAnonymizer();
  if (listener != null) {
    anonymizer.setListener(listener);
  }
  if (this.anonymizer != null) {
    anonymizer.parse(this.anonymizer);
  }
  Result result=null;
  try {
    result=anonymizer.anonymize(manager,definition,config);
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str");
  }
  if (result.optimum == null) {
    return new ARXProcessStatistics();
  }
  TransformedData data=result.checker.getApplicator().applyTransformation(result.optimum,output.getOutputBufferMicroaggregated().getDictionary());
  int newIndex=-1;
  DataMatrix oldGeneralized=output.getOutputBufferGeneralized().getArray();
  DataMatrix oldMicroaggregated=output.getOutputBufferMicroaggregated().getArray();
  DataMatrix newGeneralized=data.bufferGeneralized.getArray();
  DataMatrix newMicroaggregated=data.bufferMicroaggregated.getArray();
  try {
    int optimized=0;
    for (int oldIndex=0; oldIndex < rowset.length(); oldIndex++) {
      if (rowset.contains(oldIndex)) {
        newIndex++;
        if (oldGeneralized != null && oldGeneralized.getNumRows() != 0) {
          oldGeneralized.copyFrom(oldIndex,newGeneralized,newIndex);
          optimized+=(newGeneralized.get(newIndex,0) & Data.OUTLIER_MASK) != 0 ? 0 : 1;
        }
        if (oldMicroaggregated != null && oldMicroaggregated.getNumRows() != 0) {
          oldMicroaggregated.copyFrom(oldIndex,newMicroaggregated,newIndex);
        }
      }
    }
    output.updateDataTypes(result.optimum.getGeneralization());
    if (optimized != 0) {
      output.setOptimized(true);
    }
    time=System.currentTimeMillis() - time;
    return new ARXProcessStatistics(result,initialRecords,optimized,time);
  }
 catch (  Exception e) {
    throw new RollbackRequiredException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * This method optimizes the given data output with local recoding to improve its utility
 * @param handle
 * @param records A fraction [0,1] of records that need to be optimized.
 * @param gsFactor A factor [0,1] weighting generalization and suppression.The default value is 0.5, which means that generalization and suppression will be treated equally. A factor of 0 will favor suppression, and a factor of 1 will favor generalization. The values in between can be used for balancing both methods.
 * @param listener 
 * @return The number of optimized records
 */
public ARXProcessStatistics optimizeFast(DataHandle handle,double records,double gsFactor,ARXListener listener) throws RollbackRequiredException {
  if (listener == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (handle == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (!Double.isNaN(records) && (records <= 0d || records > 1d)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!Double.isNaN(gsFactor) && (gsFactor < 0d || gsFactor > 1d)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!(handle instanceof DataHandleOutput)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!isOptimizable(handle)) {
    return new ARXProcessStatistics();
  }
  long time=System.currentTimeMillis();
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized().getArray())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int initialRecords=0;
  RowSet rowset=RowSet.create(output.getNumRows());
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      rowset.add(row);
      initialRecords++;
    }
  }
  initialRecords=output.getNumRows() - initialRecords;
  ARXConfiguration config=this.config.getInstanceForLocalRecoding(rowset,gsFactor);
  if (!Double.isNaN(records)) {
    double absoluteRecords=records * output.getNumRows();
    double relativeRecords=absoluteRecords / (double)rowset.size();
    relativeRecords=relativeRecords < 0d ? 0d : relativeRecords;
    relativeRecords=relativeRecords > 1d ? 1d : relativeRecords;
    config.setSuppressionLimit(1d - relativeRecords);
  }
  DataDefinition definition=this.definition.clone();
  DataManager manager=this.manager.getSubsetInstance(rowset);
  ARXAnonymizer anonymizer=new ARXAnonymizer();
  if (listener != null) {
    anonymizer.setListener(listener);
  }
  if (this.anonymizer != null) {
    anonymizer.parse(this.anonymizer);
  }
  Result result=null;
  try {
    result=anonymizer.anonymize(manager,definition,config);
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str");
  }
  if (result.optimum == null) {
    return new ARXProcessStatistics();
  }
  TransformedData data=result.checker.getApplicator().applyTransformation(result.optimum,output.getOutputBufferMicroaggregated().getDictionary());
  int newIndex=-1;
  DataMatrix oldGeneralized=output.getOutputBufferGeneralized().getArray();
  DataMatrix oldMicroaggregated=output.getOutputBufferMicroaggregated().getArray();
  DataMatrix newGeneralized=data.bufferGeneralized.getArray();
  DataMatrix newMicroaggregated=data.bufferMicroaggregated.getArray();
  try {
    int optimized=0;
    for (int oldIndex=0; oldIndex < rowset.length(); oldIndex++) {
      if (rowset.contains(oldIndex)) {
        newIndex++;
        if (oldGeneralized != null && oldGeneralized.getNumRows() != 0) {
          oldGeneralized.copyFrom(oldIndex,newGeneralized,newIndex);
          optimized+=(newGeneralized.get(newIndex,0) & Data.OUTLIER_MASK) != 0 ? 0 : 1;
        }
        if (oldMicroaggregated != null && oldMicroaggregated.getNumRows() != 0) {
          oldMicroaggregated.copyFrom(oldIndex,newMicroaggregated,newIndex);
        }
      }
    }
    output.updateDataTypes(result.optimum.getGeneralization());
    if (optimized != 0) {
      output.setOptimized(true);
    }
    time=System.currentTimeMillis() - time;
    return new ARXProcessStatistics(result,initialRecords,optimized,time);
  }
 catch (  Exception e) {
    throw new RollbackRequiredException("String_Node_Str",e);
  }
}