nus-yam/ex-repair huggingface dataset:
Program: 22743
Project: 22743
Buggy source:
/** 
 * Cluster the result mismatches from the warping so pixels by types of errors.
 * @param mismatchClassification array of classified mismatches
 * @return number of warping mismatches after clustering by type
 */
public ClusteredWarpingMismatches clusterMismatchesByType(int[] mismatchClassification){
  int numOfObjectAdditions=0;
  int numOfHoleDeletions=0;
  int numOfMergers=0;
  int numOfHoleAdditions=0;
  int numOfObjectDeletions=0;
  int numOfSplits=0;
  for (int i=0; i < mismatchClassification.length; i++) {
switch (mismatchClassification[i]) {
case OBJECT_ADDITION:
      numOfObjectAdditions++;
    break;
case HOLE_DELETION:
  numOfHoleDeletions++;
break;
case MERGE:
numOfMergers++;
break;
case HOLE_ADDITION:
numOfHoleAdditions++;
break;
case OBJECT_DELETION:
numOfObjectDeletions++;
break;
case SPLIT:
numOfSplits++;
break;
default :
IJ.log("String_Node_Str");
}
}
return new ClusteredWarpingMismatches(numOfObjectAdditions,numOfHoleDeletions,numOfMergers,numOfHoleAdditions,numOfObjectDeletions,numOfSplits);
}

Fixed version (ground truth):
/** 
 * Cluster the result mismatches from the warping by types of errors.
 * @param mismatchClassification array of classified mismatches
 * @return number of warping mismatches after clustering by type
 */
public ClusteredWarpingMismatches clusterMismatchesByType(int[] mismatchClassification){
  int numOfObjectAdditions=0;
  int numOfHoleDeletions=0;
  int numOfMergers=0;
  int numOfHoleAdditions=0;
  int numOfObjectDeletions=0;
  int numOfSplits=0;
  for (int i=0; i < mismatchClassification.length; i++) {
switch (mismatchClassification[i]) {
case OBJECT_ADDITION:
      numOfObjectAdditions++;
    break;
case HOLE_DELETION:
  numOfHoleDeletions++;
break;
case MERGE:
numOfMergers++;
break;
case HOLE_ADDITION:
numOfHoleAdditions++;
break;
case OBJECT_DELETION:
numOfObjectDeletions++;
break;
case SPLIT:
numOfSplits++;
break;
default :
IJ.log("String_Node_Str");
}
}
return new ClusteredWarpingMismatches(numOfObjectAdditions,numOfHoleDeletions,numOfMergers,numOfHoleAdditions,numOfObjectDeletions,numOfSplits);
}
Program: 22744
Project: 22744
Buggy source:
public ClusteredWarpingMismatches call(){
  WarpingResults wr=simplePointWarp2d(source,target,mask,binaryThreshold);
  int[] mismatchesLabels=classifyMismatches2d(wr.warpedSource,wr.mismatches,radius);
  if (clusterByError)   return clusterMismatchesByError(wr.warpedSource,wr.mismatches,mismatchesLabels);
 else   return clusterMismatchesByType(mismatchesLabels);
}

Fixed version (ground truth):
public WarpingResults call(){
  WarpingResults wr=simplePointWarp2d(source,target,mask,binaryThreshold);
  int[] mismatchesLabels=classifyMismatches2d(wr.warpedSource,wr.mismatches,radius);
  if (calculateMismatchImage)   wr.classifiedMismatches=getMismatchImage(wr,mismatchesLabels,flags);
  ClusteredWarpingMismatches cwm=null;
  if (clusterByError)   cwm=clusterMismatchesByError(wr.warpedSource,wr.mismatches,mismatchesLabels);
 else   cwm=clusterMismatchesByType(mismatchesLabels);
  double error=0;
  double count=source.getWidth() * source.getHeight();
  if ((flags & HOLE_ADDITION) != 0)   error+=cwm.numOfHoleAdditions;
  if ((flags & HOLE_DELETION) != 0)   error+=cwm.numOfHoleDeletions;
  if ((flags & MERGE) != 0)   error+=cwm.numOfMergers;
  if ((flags & OBJECT_ADDITION) != 0)   error+=cwm.numOfObjectAdditions;
  if ((flags & OBJECT_DELETION) != 0)   error+=cwm.numOfObjectDeletions;
  if ((flags & SPLIT) != 0)   error+=cwm.numOfSplits;
  wr.warpingError=error / count;
  return wr;
}
Program: 22745
Project: 22745
Buggy source:
/** 
 * Calculate warping error and return the related result images and values.
 * @param binaryThreshold threshold value to binarize proposal (larger than 0 and smaller than 1)
 * @param calculateMismatchImage flag to calculate mismatch image
 * @param radius radius in pixels to use when classifiying mismatches
 * @return total warping error (it counts all type of mismatches as errors)
 */
public WarpingResults getWarpingResults(double binaryThreshold,boolean calculateMismatchImage,int radius){
  if (verbose)   IJ.log("String_Node_Str");
  WarpingResults[] wrs=simplePointWarp2dMT(binaryThreshold,calculateMismatchImage,radius);
  if (null == wrs)   return null;
  WarpingResults result=new WarpingResults();
  result.warpingError=0;
  ImageStack is=new ImageStack(originalLabels.getWidth(),originalLabels.getHeight());
  ImageStack is2=calculateMismatchImage ? new ImageStack(originalLabels.getWidth(),originalLabels.getHeight()) : null;
  for (int i=0; i < wrs.length; i++) {
    result.warpingError+=wrs[i].warpingError;
    is.addSlice("String_Node_Str" + (i + 1),wrs[i].warpedSource.getProcessor());
    if (calculateMismatchImage)     is2.addSlice("String_Node_Str" + (i + 1),wrs[i].classifiedMismatches.getProcessor());
  }
  result.warpedSource=new ImagePlus("String_Node_Str",is);
  if (calculateMismatchImage)   result.classifiedMismatches=new ImagePlus("String_Node_Str",is2);
  if (wrs.length != 0)   result.warpingError/=wrs.length;
  return result;
}

Fixed version (ground truth):
/** 
 * Calculate warping error and return the related result images and values.
 * @param binaryThreshold threshold value to binarize proposal (larger than 0 and smaller than 1)
 * @param clusterByError if false, cluster topology errors by type, otherwise cluster by type and mistake
 * @param calculateMismatchImage flag to calculate mismatch image
 * @param radius radius in pixels to use when classifiying mismatches
 * @return total warping error (it counts all type of mismatches as errors)
 */
public WarpingResults getWarpingResults(double binaryThreshold,boolean clusterByError,boolean calculateMismatchImage,int radius){
  if (verbose)   IJ.log("String_Node_Str");
  WarpingResults[] wrs=simplePointWarp2dMT(binaryThreshold,clusterByError,calculateMismatchImage,radius);
  if (null == wrs)   return null;
  WarpingResults result=new WarpingResults();
  result.warpingError=0;
  ImageStack is=new ImageStack(originalLabels.getWidth(),originalLabels.getHeight());
  ImageStack is2=calculateMismatchImage ? new ImageStack(originalLabels.getWidth(),originalLabels.getHeight()) : null;
  for (int i=0; i < wrs.length; i++) {
    result.warpingError+=wrs[i].warpingError;
    is.addSlice("String_Node_Str" + (i + 1),wrs[i].warpedSource.getProcessor());
    if (calculateMismatchImage)     is2.addSlice("String_Node_Str" + (i + 1),wrs[i].classifiedMismatches.getProcessor());
  }
  result.warpedSource=new ImagePlus("String_Node_Str",is);
  if (calculateMismatchImage)   result.classifiedMismatches=new ImagePlus("String_Node_Str",is2);
  if (wrs.length != 0)   result.warpingError/=wrs.length;
  return result;
}
Program: 22747
Project: 22747
Buggy source:
/** 
 * Get pixel error between two image in a concurrent way  (to be submitted to an Executor Service). 
 * @param image1 first image
 * @param image2 second image
 * @return pixel error
 */
public static Callable<Double> getPixelErrorConcurrent(final ImageProcessor image1,final ImageProcessor image2){
  return new Callable<Double>(){
    public Double call(){
      double pixelError=0;
      for (int x=0; x < image1.getWidth(); x++)       for (int y=0; y < image2.getWidth(); y++) {
        double pix1=image1.getPixelValue(x,y);
        double pix2=image2.getPixelValue(x,y);
        pixelError+=(pix1 - pix2) * (pix1 - pix2);
      }
      return Math.sqrt(pixelError);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Get pixel error between two image in a concurrent way  (to be submitted to an Executor Service). 
 * @param image1 first image
 * @param image2 second image
 * @return pixel error
 */
public static Callable<Double> getPixelErrorConcurrent(final ImageProcessor image1,final ImageProcessor image2){
  return new Callable<Double>(){
    public Double call(){
      double pixelError=0;
      for (int x=0; x < image1.getWidth(); x++) {
        for (int y=0; y < image1.getHeight(); y++) {
          double pix1=image1.getPixelValue(x,y);
          double pix2=image2.getPixelValue(x,y);
          pixelError+=(pix1 - pix2) * (pix1 - pix2);
        }
      }
      return Math.sqrt(pixelError / (image1.getWidth() * image1.getHeight()));
    }
  }
;
}
Program: 22748
Project: 22748
Buggy source:
/** 
 * Calculate the pixel error in 2D between some original labels  and the corresponding proposed labels.
 * @param label original labels (single 2D image or stack)
 * @param proposal proposed new labels (single 2D image or stack of the same as as the original labels)
 * @return pixel error
 */
public static double pixelError(ImagePlus label,ImagePlus proposal){
  if (label.getWidth() != proposal.getWidth() || label.getHeight() != proposal.getHeight() || label.getImageStackSize() != proposal.getImageStackSize()) {
    IJ.log("String_Node_Str");
    return -1;
  }
  final ImageStack labelSlices=label.getImageStack();
  final ImageStack proposalSlices=proposal.getImageStack();
  double pixelError=0;
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<Double>> futures=new ArrayList<Future<Double>>();
  try {
    for (int i=1; i <= labelSlices.getSize(); i++) {
      futures.add(exe.submit(getPixelErrorConcurrent(labelSlices.getProcessor(i).convertToFloat(),proposalSlices.getProcessor(i).convertToFloat())));
    }
    for (    Future<Double> f : futures) {
      pixelError+=f.get();
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  final double numPixels=label.getWidth() * label.getHeight() * label.getImageStackSize();
  return pixelError / numPixels;
}

Fixed version (ground truth):
/** 
 * Calculate the pixel error in 2D between some original labels  and the corresponding proposed labels.
 * @param label original labels (single 2D image or stack)
 * @param proposal proposed new labels (single 2D image or stack of the same as as the original labels)
 * @return pixel error
 */
public static double pixelError(ImagePlus label,ImagePlus proposal){
  if (label.getWidth() != proposal.getWidth() || label.getHeight() != proposal.getHeight() || label.getImageStackSize() != proposal.getImageStackSize()) {
    IJ.log("String_Node_Str");
    return -1;
  }
  final ImageStack labelSlices=label.getImageStack();
  final ImageStack proposalSlices=proposal.getImageStack();
  double pixelError=0;
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<Double>> futures=new ArrayList<Future<Double>>();
  try {
    for (int i=1; i <= labelSlices.getSize(); i++) {
      futures.add(exe.submit(getPixelErrorConcurrent(labelSlices.getProcessor(i).convertToFloat(),proposalSlices.getProcessor(i).convertToFloat())));
    }
    for (    Future<Double> f : futures) {
      pixelError+=f.get();
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  return pixelError;
}
Program: 22749
Project: 22749
Buggy source:
/** 
 * Get pixel error between two image in a concurrent way  (to be submitted to an Executor Service). 
 * @param image1 first image
 * @param image2 second image
 * @return pixel error
 */
public static Callable<Double> getPixelErrorConcurrent(final ImageProcessor image1,final ImageProcessor image2){
  return new Callable<Double>(){
    public Double call(){
      double pixelError=0;
      for (int x=0; x < image1.getWidth(); x++) {
        for (int y=0; y < image1.getHeight(); y++) {
          double pix1=image1.getPixelValue(x,y);
          double pix2=image2.getPixelValue(x,y);
          pixelError+=(pix1 - pix2) * (pix1 - pix2);
        }
      }
      return Math.sqrt(pixelError / (image1.getWidth() * image1.getHeight()));
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Get pixel error between two image in a concurrent way  (to be submitted to an Executor Service). 
 * @param image1 first image
 * @param image2 second image
 * @return pixel error
 */
public static Callable<Double> getPixelErrorConcurrent(final ImageProcessor image1,final ImageProcessor image2){
  return new Callable<Double>(){
    public Double call(){
      double pixelError=0;
      for (int x=0; x < image1.getWidth(); x++) {
        for (int y=0; y < image1.getHeight(); y++) {
          double pix1=image1.getPixelValue(x,y);
          double pix2=image2.getPixelValue(x,y);
          pixelError+=(pix1 - pix2) * (pix1 - pix2);
        }
      }
      return pixelError / (image1.getWidth() * image1.getHeight());
    }
  }
;
}
Program: 22750
Project: 22750
Buggy source:
/** 
 * Calculate the pixel error in 2D between some original labels  and the corresponding proposed labels.
 * @param label original labels (single 2D image or stack)
 * @param proposal proposed new labels (single 2D image or stack of the same as as the original labels)
 * @return pixel error
 */
public static double pixelError(ImagePlus label,ImagePlus proposal){
  if (label.getWidth() != proposal.getWidth() || label.getHeight() != proposal.getHeight() || label.getImageStackSize() != proposal.getImageStackSize()) {
    IJ.log("String_Node_Str");
    return -1;
  }
  final ImageStack labelSlices=label.getImageStack();
  final ImageStack proposalSlices=proposal.getImageStack();
  double pixelError=0;
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<Double>> futures=new ArrayList<Future<Double>>();
  try {
    for (int i=1; i <= labelSlices.getSize(); i++) {
      futures.add(exe.submit(getPixelErrorConcurrent(labelSlices.getProcessor(i).convertToFloat(),proposalSlices.getProcessor(i).convertToFloat())));
    }
    for (    Future<Double> f : futures) {
      pixelError+=f.get();
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  return pixelError;
}

Fixed version (ground truth):
/** 
 * Calculate the pixel error in 2D between some original labels  and the corresponding proposed labels.
 * @param label original labels (single 2D image or stack)
 * @param proposal proposed new labels (single 2D image or stack of the same as as the original labels)
 * @return pixel error
 */
public static double pixelError(ImagePlus label,ImagePlus proposal){
  if (label.getWidth() != proposal.getWidth() || label.getHeight() != proposal.getHeight() || label.getImageStackSize() != proposal.getImageStackSize()) {
    IJ.log("String_Node_Str");
    return -1;
  }
  final ImageStack labelSlices=label.getImageStack();
  final ImageStack proposalSlices=proposal.getImageStack();
  double pixelError=0;
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<Double>> futures=new ArrayList<Future<Double>>();
  try {
    for (int i=1; i <= labelSlices.getSize(); i++) {
      futures.add(exe.submit(getPixelErrorConcurrent(labelSlices.getProcessor(i).convertToFloat(),proposalSlices.getProcessor(i).convertToFloat())));
    }
    for (    Future<Double> f : futures) {
      pixelError+=f.get();
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  return pixelError / labelSlices.getSize();
}
Program: 22753
Project: 22753
Buggy source:
/** 
 * Merge three image stack into a color stack (doing scaling)
 * @param redChannel image stack representing the red channel 
 * @param greenChannel image stack representing the green channel
 * @param blueChannel image stack representing the blue channel
 * @return RGB merged stack
 */
ImageStack mergeStacks(ImageStack redChannel,ImageStack greenChannel,ImageStack blueChannel){
  final ImageStack colorStack=new ImageStack(redChannel.getWidth(),redChannel.getHeight());
  for (int n=1; n <= redChannel.getSize(); n++) {
    final ByteProcessor red=create8BitImage((FloatProcessor)(redChannel.getProcessor(n)));
    final ByteProcessor green=create8BitImage((FloatProcessor)(greenChannel.getProcessor(n)));
    final ByteProcessor blue=create8BitImage((FloatProcessor)(blueChannel.getProcessor(n)));
    final ColorProcessor cp=new ColorProcessor(redChannel.getWidth(),redChannel.getHeight());
    cp.setRGB((byte[])red.getPixels(),(byte[])green.getPixels(),(byte[])blue.getPixels());
    colorStack.addSlice(redChannel.getSliceLabel(n),cp);
  }
  return colorStack;
}

Fixed version (ground truth):
/** 
 * Merge three image stack into a color stack (no scaling)
 * @param redChannel image stack representing the red channel 
 * @param greenChannel image stack representing the green channel
 * @param blueChannel image stack representing the blue channel
 * @return RGB merged stack
 */
ImageStack mergeStacks(ImageStack redChannel,ImageStack greenChannel,ImageStack blueChannel){
  final ImageStack colorStack=new ImageStack(redChannel.getWidth(),redChannel.getHeight());
  for (int n=1; n <= redChannel.getSize(); n++) {
    final ByteProcessor red=(ByteProcessor)redChannel.getProcessor(n).convertToByte(false);
    final ByteProcessor green=(ByteProcessor)greenChannel.getProcessor(n).convertToByte(false);
    final ByteProcessor blue=(ByteProcessor)blueChannel.getProcessor(n).convertToByte(false);
    final ColorProcessor cp=new ColorProcessor(redChannel.getWidth(),redChannel.getHeight());
    cp.setRGB((byte[])red.getPixels(),(byte[])green.getPixels(),(byte[])blue.getPixels());
    colorStack.addSlice(redChannel.getSliceLabel(n),cp);
  }
  return colorStack;
}
Program: 22754
Project: 22754
Buggy source:
/** 
 * Calculate the classic topology-preserving warping error in 2D between some original labels and the corresponding proposed labels. Both, original and proposed labels are expected to have float values between 0 and 1.  Otherwise, they will be converted.
 * @param label original labels (single 2D image or stack)
 * @param proposal proposed new labels (single 2D image or stack of the same as as the original labels)
 * @param mask image mask containing in white the areas where warping is allowed (null for not geometrical constraints)
 * @param binaryThreshold threshold value to binarize proposal (larger than 0 and smaller than 1)
 * @return total warping error (it counts all type of mismatches as errors)
 */
public static double warpingError(ImagePlus label,ImagePlus proposal,ImagePlus mask,double binaryThreshold){
  IJ.log("String_Node_Str");
  WarpingResults[] wrs=WekaSegmentation.simplePointWarp2dMT(label,proposal,mask,binaryThreshold);
  if (null == wrs)   return -1;
  double error=0;
  double count=label.getWidth() * label.getHeight() * label.getImageStackSize();
  for (int j=0; j < wrs.length; j++)   error+=wrs[j].mismatches.size();
  if (count != 0)   return error / count;
 else   return -1;
}

Fixed version (ground truth):
/** 
 * Calculate the classic topology-preserving warping error in 2D between some original labels and the corresponding proposed labels. Both, original and proposed labels are expected to have float values between 0 and 1.  Otherwise, they will be converted.
 * @param label original labels (single 2D image or stack)
 * @param proposal proposed new labels (single 2D image or stack of the same as as the original labels)
 * @param mask image mask containing in white the areas where warping is allowed (null for not geometrical constraints)
 * @param binaryThreshold threshold value to binarize proposal (larger than 0 and smaller than 1)
 * @return total warping error (it counts all type of mismatches as errors)
 */
public static double warpingError(ImagePlus label,ImagePlus proposal,ImagePlus mask,double binaryThreshold){
  IJ.log("String_Node_Str");
  WarpingResults[] wrs=WekaSegmentation.simplePointWarp2dMT(label,proposal,mask,binaryThreshold);
  if (null == wrs)   return -1;
  double error=0;
  double count=label.getWidth() * label.getHeight() * label.getImageStackSize();
  for (int j=0; j < wrs.length; j++)   error+=wrs[j].warpingError;
  if (count != 0)   return error / wrs.length;
 else   return -1;
}
Program: 22758
Project: 22758
Buggy source:
public double[][] call(){
  final int numInstances=data.numInstances();
  final int numClasses=data.numClasses();
  final double[][] classificationResult;
  if (probabilityMaps)   classificationResult=new double[numClasses][numInstances];
 else   classificationResult=new double[1][numInstances];
  for (int i=0; i < numInstances; i++) {
    try {
      if (0 == i % 4000) {
        if (Thread.currentThread().isInterrupted())         return null;
        counter.addAndGet(4000);
      }
      if (probabilityMaps) {
        double[] prob=classifier.distributionForInstance(data.get(i));
        for (int k=0; k < numClasses; k++)         classificationResult[k][i]=prob[k];
      }
 else {
        if (null == data.get(i))         IJ.log("String_Node_Str" + i + "String_Node_Str");
 else         classificationResult[0][i]=classifier.classifyInstance(data.get(i));
      }
    }
 catch (    Exception e) {
      IJ.showMessage("String_Node_Str");
      e.printStackTrace();
      return null;
    }
  }
  return classificationResult;
}

Fixed version (ground truth):
public double[][] call(){
  final int numInstances=data.numInstances();
  final int numClasses=data.numClasses();
  final double[][] classificationResult;
  if (probabilityMaps)   classificationResult=new double[numClasses][numInstances];
 else   classificationResult=new double[1][numInstances];
  for (int i=0; i < numInstances; i++) {
    try {
      if (0 == i % 4000) {
        if (Thread.currentThread().isInterrupted())         return null;
        counter.addAndGet(4000);
      }
      if (probabilityMaps) {
        double[] prob=classifier.distributionForInstance(data.get(i));
        for (int k=0; k < numClasses; k++)         classificationResult[k][i]=prob[k];
      }
 else {
        classificationResult[0][i]=classifier.classifyInstance(data.get(i));
      }
    }
 catch (    Exception e) {
      IJ.showMessage("String_Node_Str");
      e.printStackTrace();
      return null;
    }
  }
  return classificationResult;
}
Program: 22768
Project: 22768
Buggy source:
public ImageProcessingThread(int numThread,int numProcessors,File[] imageFiles,boolean storeResults,boolean showResults,String storeDir){
  this.numThread=numThread;
  this.numProcessors=numProcessors;
  this.imageFiles=imageFiles;
  this.storeResults=storeResults;
  this.showResults=showResults;
  this.storeDir=storeDir;
}

Fixed version (ground truth):
public ImageProcessingThread(int numThread,int numThreads,File[] imageFiles,boolean storeResults,boolean showResults,String storeDir){
  this.numThread=numThread;
  this.numThreads=numThreads;
  this.imageFiles=imageFiles;
  this.storeResults=storeResults;
  this.showResults=showResults;
  this.storeDir=storeDir;
}
Program: 22776
Project: 22776
Buggy source:
/** 
 * Filter feature stack based on the list of feature names to use	
 * @param featureNames list of feature names to use
 * @param featureStack feature stack to filter
 */
public static void filterFeatureStackByList(ArrayList<String> featureNames,FeatureStack featureStack){
  if (null == featureNames)   return;
  for (int i=1; i <= featureStack.getSize(); i++) {
    final String featureName=featureStack.getSliceLabel(i);
    IJ.log("String_Node_Str" + featureName + "String_Node_Str");
    if (false == featureNames.contains(featureName)) {
      featureStack.removeFeature(featureName);
      i--;
    }
  }
  featureStack.show();
}

Fixed version (ground truth):
/** 
 * Filter feature stack based on the list of feature names to use	
 * @param featureNames list of feature names to use
 * @param featureStack feature stack to filter
 */
public static void filterFeatureStackByList(ArrayList<String> featureNames,FeatureStack featureStack){
  IJ.log("String_Node_Str");
  if (null == featureNames)   return;
  for (int i=1; i <= featureStack.getSize(); i++) {
    final String featureName=featureStack.getSliceLabel(i);
    if (false == featureNames.contains(featureName)) {
      featureStack.removeFeature(featureName);
      i--;
    }
  }
}
Program: 22779
Project: 22779
Buggy source:
/** 
 * Select attributes to reduce the number of parameters per instance
 * @param data input set of instances
 * @return resampled set of instances
 */
public static Instances selectAttributes(Instances data){
  final AttributeSelection filter=new AttributeSelection();
  Instances filteredIns=null;
  final CfsSubsetEval evaluator=new CfsSubsetEval();
  evaluator.setMissingSeparate(true);
  filter.setEvaluator(evaluator);
  final BestFirst search=new BestFirst();
  filter.setSearch(search);
  try {
    filter.setInputFormat(data);
    filteredIns=Filter.useFilter(data,filter);
  }
 catch (  Exception e) {
    IJ.log("String_Node_Str");
    e.printStackTrace();
  }
  return filteredIns;
}

Fixed version (ground truth):
/** 
 * Select attributes using BestFirst search to reduce  the number of parameters per instance of a dataset
 * @param data input set of instances
 * @return resampled set of instances
 */
public static Instances selectAttributes(Instances data){
  final AttributeSelection filter=new AttributeSelection();
  Instances filteredIns=null;
  final CfsSubsetEval evaluator=new CfsSubsetEval();
  evaluator.setMissingSeparate(true);
  filter.setEvaluator(evaluator);
  final BestFirst search=new BestFirst();
  filter.setSearch(search);
  try {
    filter.setInputFormat(data);
    filteredIns=Filter.useFilter(data,filter);
  }
 catch (  Exception e) {
    IJ.log("String_Node_Str");
    e.printStackTrace();
  }
  return filteredIns;
}
Program: 22782
Project: 22782
Buggy source:
/** 
 * Update buttons enabling depending on the current status of the plugin
 */
private void updateButtonsEnabling(){
  if (useGUI) {
    final boolean classifierExists=null != this.classifier;
    trainButton.setEnabled(classifierExists);
    applyButton.setEnabled(classifierExists);
    final boolean resultExists=null != this.classifiedImage && null != this.classifiedImage.getProcessor();
    saveClassifierButton.setEnabled(resultExists);
    overlayButton.setEnabled(resultExists);
    resultButton.setEnabled(resultExists);
    probabilityButton.setEnabled(resultExists);
    newImageButton.setEnabled(true);
    loadClassifierButton.setEnabled(true);
    loadDataButton.setEnabled(true);
    addClassButton.setEnabled(this.numOfClasses < MAX_NUM_CLASSES);
    settingsButton.setEnabled(true);
    wekaButton.setEnabled(true);
    boolean examplesEmpty=true;
    for (int i=0; i < numOfClasses; i++)     if (examples[i].size() > 0) {
      examplesEmpty=false;
      break;
    }
    saveDataButton.setEnabled(!examplesEmpty || null != loadedTrainingData);
    for (int i=0; i < numOfClasses; i++) {
      exampleList[i].setEnabled(true);
      addExampleButton[i].setEnabled(true);
    }
  }
}

Fixed version (ground truth):
/** 
 * Update buttons enabling depending on the current status of the plugin
 */
private void updateButtonsEnabling(){
  if (useGUI) {
    final boolean classifierExists=null != this.classifier;
    trainButton.setEnabled(classifierExists);
    applyButton.setEnabled(classifierExists);
    final boolean resultExists=null != this.classifiedImage && null != this.classifiedImage.getProcessor();
    saveClassifierButton.setEnabled(resultExists);
    overlayButton.setEnabled(resultExists);
    resultButton.setEnabled(resultExists);
    probabilityButton.setEnabled(classifierExists);
    newImageButton.setEnabled(true);
    loadClassifierButton.setEnabled(true);
    loadDataButton.setEnabled(true);
    addClassButton.setEnabled(this.numOfClasses < MAX_NUM_CLASSES);
    settingsButton.setEnabled(true);
    wekaButton.setEnabled(true);
    boolean examplesEmpty=true;
    for (int i=0; i < numOfClasses; i++)     if (examples[i].size() > 0) {
      examplesEmpty=false;
      break;
    }
    saveDataButton.setEnabled(!examplesEmpty || null != loadedTrainingData);
    for (int i=0; i < numOfClasses; i++) {
      exampleList[i].setEnabled(true);
      addExampleButton[i].setEnabled(true);
    }
  }
}
Program: 22783
Project: 22783
Buggy source:
/** 
 * Display the current probability maps 
 */
void showProbabilityImage(){
  this.setButtonsEnabled(false);
  final ImagePlus probImage=this.getProbabilityMapsMT();
  if (null != probImage)   probImage.show();
  this.updateButtonsEnabling();
}

Fixed version (ground truth):
/** 
 * Display the current probability maps 
 */
void showProbabilityImage(){
  IJ.showStatus("String_Node_Str");
  IJ.log("String_Node_Str");
  this.setButtonsEnabled(false);
  final ImagePlus probImage=this.getProbabilityMapsMT();
  if (null != probImage)   probImage.show();
  this.updateButtonsEnabling();
  IJ.showStatus("String_Node_Str");
  IJ.log("String_Node_Str");
}
Program: 22788
Project: 22788
Buggy source:
/** 
 * Save training model into a file
 */
public void saveTrainingData(){
  boolean examplesEmpty=true;
  for (int i=0; i < numOfClasses; i++)   if (examples[i].size() > 0) {
    examplesEmpty=false;
    break;
  }
  if (examplesEmpty && loadedTrainingData == null) {
    IJ.showMessage("String_Node_Str");
    return;
  }
  Instances data=createTrainingInstances();
  data.setClassIndex(data.numAttributes() - 1);
  if (null != loadedTrainingData && null != data) {
    IJ.log("String_Node_Str");
    for (int i=0; i < loadedTrainingData.numInstances(); i++) {
      data.add(loadedTrainingData.instance(i));
    }
    IJ.log("String_Node_Str");
  }
 else   if (null == data)   data=loadedTrainingData;
  SaveDialog sd=new SaveDialog("String_Node_Str","String_Node_Str","String_Node_Str");
  if (sd.getFileName() == null)   return;
  IJ.log("String_Node_Str" + data.numInstances() + "String_Node_Str");
  writeDataToARFF(data,sd.getDirectory() + sd.getFileName());
  IJ.log("String_Node_Str" + sd.getDirectory() + "String_Node_Str"+ sd.getFileName());
}

Fixed version (ground truth):
/** 
 * Save training model into a file
 */
public void saveTrainingData(){
  boolean examplesEmpty=true;
  for (int i=0; i < numOfClasses; i++)   if (examples[i].size() > 0) {
    examplesEmpty=false;
    break;
  }
  if (examplesEmpty && loadedTrainingData == null) {
    IJ.showMessage("String_Node_Str");
    return;
  }
  if (featureStack.getSize() < 2) {
    setButtonsEnabled(false);
    featureStack.updateFeatures();
    setButtonsEnabled(true);
  }
  Instances data=createTrainingInstances();
  data.setClassIndex(data.numAttributes() - 1);
  if (null != loadedTrainingData && null != data) {
    IJ.log("String_Node_Str");
    for (int i=0; i < loadedTrainingData.numInstances(); i++) {
      data.add(loadedTrainingData.instance(i));
    }
    IJ.log("String_Node_Str");
  }
 else   if (null == data)   data=loadedTrainingData;
  SaveDialog sd=new SaveDialog("String_Node_Str","String_Node_Str","String_Node_Str");
  if (sd.getFileName() == null)   return;
  IJ.log("String_Node_Str" + data.numInstances() + "String_Node_Str");
  writeDataToARFF(data,sd.getDirectory() + sd.getFileName());
  IJ.log("String_Node_Str" + sd.getDirectory() + "String_Node_Str"+ sd.getFileName());
}
Program: 22789
Project: 22789
Buggy source:
/** 
 * Call the Weka chooser
 */
public static void launchWeka(){
  IJ.log("String_Node_Str" + ClassLoader.getSystemClassLoader());
  GUIChooser chooser=new GUIChooser();
  for (  WindowListener wl : chooser.getWindowListeners()) {
    chooser.removeWindowListener(wl);
  }
  chooser.setVisible(true);
}

Fixed version (ground truth):
/** 
 * Call the Weka chooser
 */
public static void launchWeka(){
  IJ.log("String_Node_Str" + ClassLoader.getSystemClassLoader());
  weka.gui.GUIChooser chooser=new weka.gui.GUIChooser();
  for (  WindowListener wl : chooser.getWindowListeners()) {
    chooser.removeWindowListener(wl);
  }
  chooser.setVisible(true);
}
Program: 22790
Project: 22790
Buggy source:
/** 
 * Read header classifier from a .model file
 * @param filename complete path and file name
 * @return false if error
 */
public boolean loadClassifier(String filename){
  File selected=new File(filename);
  try {
    InputStream is=new FileInputStream(selected);
    if (selected.getName().endsWith(ClassifierPanel.PMML_FILE_EXTENSION)) {
      PMMLModel model=PMMLFactory.getPMMLModel(is,null);
      if (model instanceof PMMLClassifier)       classifier=(PMMLClassifier)model;
 else       throw new Exception("String_Node_Str");
    }
 else {
      if (selected.getName().endsWith("String_Node_Str"))       is=new GZIPInputStream(is);
      ObjectInputStream objectInputStream=new ObjectInputStream(is);
      classifier=(AbstractClassifier)objectInputStream.readObject();
      try {
        trainHeader=(Instances)objectInputStream.readObject();
      }
 catch (      Exception e) {
        IJ.error("String_Node_Str","String_Node_Str");
        return false;
      }
 finally {
        objectInputStream.close();
      }
    }
  }
 catch (  Exception e) {
    IJ.error("String_Node_Str","String_Node_Str");
    e.printStackTrace();
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Read header classifier from a .model file
 * @param filename complete path and file name
 * @return false if error
 */
public boolean loadClassifier(String filename){
  Thread t=Thread.currentThread();
  t.setContextClassLoader(ClassLoader.getSystemClassLoader());
  IJ.log("String_Node_Str" + t.getContextClassLoader().getClass());
  File selected=new File(filename);
  try {
    InputStream is=new FileInputStream(selected);
    if (selected.getName().endsWith(weka.gui.explorer.ClassifierPanel.PMML_FILE_EXTENSION)) {
      weka.core.pmml.PMMLModel model=weka.core.pmml.PMMLFactory.getPMMLModel(is,null);
      if (model instanceof weka.classifiers.pmml.consumer.PMMLClassifier)       classifier=(weka.classifiers.pmml.consumer.PMMLClassifier)model;
 else       throw new Exception("String_Node_Str");
    }
 else {
      if (selected.getName().endsWith("String_Node_Str"))       is=new GZIPInputStream(is);
      ObjectInputStream objectInputStream=new ObjectInputStream(is);
      classifier=(AbstractClassifier)objectInputStream.readObject();
      try {
        trainHeader=(Instances)objectInputStream.readObject();
      }
 catch (      Exception e) {
        IJ.error("String_Node_Str","String_Node_Str");
        return false;
      }
 finally {
        objectInputStream.close();
      }
    }
  }
 catch (  Exception e) {
    IJ.error("String_Node_Str","String_Node_Str");
    e.printStackTrace();
    return false;
  }
  return true;
}
Program: 22792
Project: 22792
Buggy source:
private void addPositiveExamples(){
  Roi r=displayImage.getRoi();
  displayImage.killRoi();
  positiveExamples.add(r);
  posExampleList.add("String_Node_Str" + posTraceCounter);
  posTraceCounter++;
  drawExamples();
}

Fixed version (ground truth):
private void addPositiveExamples(){
  Roi r=displayImage.getRoi();
  if (null == r) {
    return;
  }
  displayImage.killRoi();
  positiveExamples.add(r);
  posExampleList.add("String_Node_Str" + posTraceCounter);
  posTraceCounter++;
  drawExamples();
}
Program: 22793
Project: 22793
Buggy source:
private void addNegativeExamples(){
  Roi r=displayImage.getRoi();
  displayImage.killRoi();
  negativeExamples.add(r);
  negExampleList.add("String_Node_Str" + negTraceCounter);
  negTraceCounter++;
  drawExamples();
}

Fixed version (ground truth):
private void addNegativeExamples(){
  Roi r=displayImage.getRoi();
  if (null == r) {
    return;
  }
  displayImage.killRoi();
  negativeExamples.add(r);
  negExampleList.add("String_Node_Str" + negTraceCounter);
  negTraceCounter++;
  drawExamples();
}
Program: 22794
Project: 22794
Buggy source:
@Override public Cursor loadInBackground(){
  Cursor cursor=super.loadInBackground();
  MatrixCursor prepend=new MatrixCursor(cursor.getColumnNames());
  onPrependDummy(prepend);
  MatrixCursor append=new MatrixCursor(cursor.getColumnNames());
  onAppendDummy(append);
  return new MergeCursor(new Cursor[]{prepend,cursor,append});
}

Fixed version (ground truth):
@Override public Cursor loadInBackground(){
  Cursor cursor=super.loadInBackground();
  MatrixCursor prepend=new MatrixCursor(getProjection());
  onPrependDummy(prepend);
  MatrixCursor append=new MatrixCursor(getProjection());
  onAppendDummy(append);
  return new MergeCursor(new Cursor[]{prepend,cursor,append});
}
Program: 22795
Project: 22795
Buggy source:
@Override public void bindView(View view,Context context,Cursor cursor){
  TextView albumName=(TextView)view.findViewById(R.id.label_album_name);
  BucketId bucketId=BucketId.from(cursor);
  if (bucketId.equals(FixedBucketIdFactory.CAMERA.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.CAMERA.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.DOWNLOAD.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.DOWNLOAD.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.EDITED_ONLINE_PHOTO.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.EDITED_ONLINE_PHOTO.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.IMPORTED_PHOTO.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.IMPORTED_PHOTO.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.SNAP_SHOT.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.SNAP_SHOT.getLocalizedDisplayName(context));
  }
 else {
    String name=cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
    albumName.setText(name);
  }
}

Fixed version (ground truth):
@Override public void bindView(View view,Context context,Cursor cursor){
  TextView albumName=(TextView)view.findViewById(R.id.label_album_name);
  BucketId bucketId=BucketId.from(cursor);
  if (bucketId.equals(FixedBucketIdFactory.CAMERA.getBucketId())) {
    albumName.setText("String_Node_Str" + FixedBucketIdFactory.CAMERA.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.DOWNLOAD.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.DOWNLOAD.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.EDITED_ONLINE_PHOTO.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.EDITED_ONLINE_PHOTO.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.IMPORTED_PHOTO.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.IMPORTED_PHOTO.getLocalizedDisplayName(context));
  }
 else   if (bucketId.equals(FixedBucketIdFactory.SNAP_SHOT.getBucketId())) {
    albumName.setText(FixedBucketIdFactory.SNAP_SHOT.getLocalizedDisplayName(context));
  }
 else {
    String name=cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
    albumName.setText(name);
  }
}
Program: 22796
Project: 22796
Buggy source:
private double[] handleEntityCollision(Entity entity,double motionX,double motionZ){
  double X=motionX;
  double Z=motionZ;
  List list=this.worldObj.getCollidingBoundingBoxes(entity,entity.boundingBox.addCoord(X,0,Z));
  int j;
  for (j=0; j < list.size(); ++j) {
    X=((AxisAlignedBB)list.get(j)).calculateXOffset(entity.boundingBox,X);
  }
  entity.boundingBox.offset(X,0.0D,0.0D);
  for (j=0; j < list.size(); ++j) {
    Z=((AxisAlignedBB)list.get(j)).calculateZOffset(entity.boundingBox,motionZ);
  }
  entity.boundingBox.offset(0.0D,0.0D,motionZ);
  entity.posX=(entity.boundingBox.minX + entity.boundingBox.maxX) / 2.0D;
  entity.posZ=(entity.boundingBox.minZ + entity.boundingBox.maxZ) / 2.0D;
  entity.isCollidedHorizontally=motionX != X || motionZ != Z;
  entity.isCollided=entity.isCollidedHorizontally || entity.isCollidedVertically;
  motionX=X;
  motionZ=Z;
  return new double[]{motionX,motionZ};
}

Fixed version (ground truth):
private double[] handleEntityCollision(Entity entity,double motionX,double motionZ){
  double X=motionX;
  double Z=motionZ;
  List list=this.worldObj.getCollidingBoundingBoxes(entity,entity.boundingBox.addCoord(X,0,Z));
  int j;
  for (j=0; j < list.size(); ++j) {
    X=((AxisAlignedBB)list.get(j)).calculateXOffset(entity.boundingBox,X);
  }
  entity.boundingBox.offset(X,0.0D,0.0D);
  for (j=0; j < list.size(); ++j) {
    Z=((AxisAlignedBB)list.get(j)).calculateZOffset(entity.boundingBox,motionZ);
  }
  entity.boundingBox.offset(0.0D,0.0D,Z);
  entity.posX=(entity.boundingBox.minX + entity.boundingBox.maxX) / 2.0D;
  entity.posZ=(entity.boundingBox.minZ + entity.boundingBox.maxZ) / 2.0D;
  entity.isCollidedHorizontally=motionX != X || motionZ != Z;
  entity.isCollided=entity.isCollidedHorizontally || entity.isCollidedVertically;
  motionX=X;
  motionZ=Z;
  return new double[]{motionX,motionZ};
}
Program: 22797
Project: 22797
Buggy source:
private double[] handleEntityCollision(Entity entity,double motionX,double motionZ){
  double X=motionX;
  double Z=motionZ;
  List list=this.worldObj.getCollidingBoundingBoxes(entity,entity.boundingBox.addCoord(X,0,Z));
  int j;
  for (j=0; j < list.size(); ++j) {
    X=((AxisAlignedBB)list.get(j)).calculateXOffset(entity.boundingBox,X);
  }
  entity.boundingBox.offset(X,0.0D,0.0D);
  for (j=0; j < list.size(); ++j) {
    Z=((AxisAlignedBB)list.get(j)).calculateZOffset(entity.boundingBox,motionZ);
  }
  entity.boundingBox.offset(0.0D,0.0D,Z);
  entity.posX=(entity.boundingBox.minX + entity.boundingBox.maxX) / 2.0D;
  entity.posZ=(entity.boundingBox.minZ + entity.boundingBox.maxZ) / 2.0D;
  entity.isCollidedHorizontally=motionX != X || motionZ != Z;
  entity.isCollided=entity.isCollidedHorizontally || entity.isCollidedVertically;
  motionX=X;
  motionZ=Z;
  return new double[]{motionX,motionZ};
}

Fixed version (ground truth):
private double[] handleEntityCollision(Entity entity,double motionX,double motionZ){
  double X=motionX;
  double Z=motionZ;
  List list=this.worldObj.getCollidingBoundingBoxes(entity,entity.boundingBox.addCoord(X,0,Z));
  int j;
  for (j=0; j < list.size(); ++j) {
    X=((AxisAlignedBB)list.get(j)).calculateXOffset(entity.boundingBox,X);
  }
  entity.boundingBox.offset(X,0.0D,0.0D);
  for (j=0; j < list.size(); ++j) {
    Z=((AxisAlignedBB)list.get(j)).calculateZOffset(entity.boundingBox,Z);
  }
  entity.boundingBox.offset(0.0D,0.0D,Z);
  entity.posX=(entity.boundingBox.minX + entity.boundingBox.maxX) / 2.0D;
  entity.posZ=(entity.boundingBox.minZ + entity.boundingBox.maxZ) / 2.0D;
  entity.isCollidedHorizontally=motionX != X || motionZ != Z;
  entity.isCollided=entity.isCollidedHorizontally || entity.isCollidedVertically;
  motionX=X;
  motionZ=Z;
  return new double[]{motionX,motionZ};
}
Program: 22798
Project: 22798
Buggy source:
private static void postEvent(Event e){
  try {
    eventPhase.set(e,null);
  }
 catch (  IllegalArgumentException|IllegalAccessException e1) {
    throw (new RuntimeException(e1));
  }
  RiMRegistry.blockMoveBus.post(e);
}

Fixed version (ground truth):
private static void postEvent(Event e){
  try {
    eventPhase.set(e,null);
  }
 catch (  IllegalArgumentException e1) {
    throw (new RuntimeException(e1));
  }
catch (  IllegalAccessException e1) {
    throw (new RuntimeException(e1));
  }
  RiMRegistry.blockMoveBus.post(e);
}
Program: 22799
Project: 22799
Buggy source:
public void handleChickenChunks(World worldObj,BlockRecord record,BlockRecord newPosition){
  if (record.entityRecord == null)   return;
  TileEntity te=worldObj.getTileEntity(record.X,record.Y,record.Z);
  if (te != null) {
    if (te instanceof TileChunkLoaderBase) {
      if (record.X >> 4 != newPosition.X >> 4 && record.Z >> 4 != newPosition.Z >> 4) {
        if (((TileChunkLoaderBase)te).active) {
          NBTTagCompound tag=new NBTTagCompound();
          ChickenChunkLoader loader=new ChickenChunkLoader((TileChunkLoaderBase)te);
          loader.writeToNBT(tag);
          record.entityRecord.setTag("String_Node_Str",tag);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void handleChickenChunks(World worldObj,BlockRecord record,BlockRecord newPosition){
  if (record.entityRecord == null)   return;
  TileEntity te=worldObj.getTileEntity(record.X,record.Y,record.Z);
  if (te != null) {
    if (te instanceof TileChunkLoaderBase) {
      if (!(record.X >> 4 == newPosition.X >> 4 && record.Z >> 4 == newPosition.Z >> 4)) {
        if (((TileChunkLoaderBase)te).active) {
          NBTTagCompound tag=new NBTTagCompound();
          ChickenChunkLoader loader=new ChickenChunkLoader((TileChunkLoaderBase)te);
          loader.writeToNBT(tag);
          record.entityRecord.setTag("String_Node_Str",tag);
        }
      }
    }
  }
}
Program: 22801
Project: 22801
Buggy source:
@EventHandler public void ServerStopping(FMLServerStoppingEvent Event){
  try {
    TileEntityCarriageTranslocator.ActiveTranslocatorSets.clear();
  }
 catch (  Error e) {
  }
}

Fixed version (ground truth):
@EventHandler public void ServerStopping(FMLServerStoppingEvent Event){
  TileEntityCarriageTranslocator.ActiveTranslocatorSets.clear();
  TileEntityCarriageTransduplicator.ActiveTranslocatorSets.clear();
}
Program: 22802
Project: 22802
Buggy source:
@Override public void WriteCommonRecord(NBTTagCompound TagCompound){
  super.WriteCommonRecord(TagCompound);
  if (Player == null)   Player="String_Node_Str";
  TagCompound.setString("String_Node_Str",Player);
  TagCompound.setInteger("String_Node_Str",Label);
}

Fixed version (ground truth):
@Override public void WriteCommonRecord(NBTTagCompound TagCompound){
  super.WriteCommonRecord(TagCompound);
  TagCompound.setString("String_Node_Str",Player);
  TagCompound.setInteger("String_Node_Str",Label);
}
Program: 22803
Project: 22803
Buggy source:
public void setConfiguration(long flags,EntityPlayerMP changer){
  unregisterLabel();
  super.setConfiguration(flags,changer);
  flags=flags >> 3;
  Label=(int)(flags & 0xFFFFl);
  if ((flags & (1 << (Buttons.PRIVATE.ordinal() + 3))) != 0) {
    Player=changer.getDisplayName();
  }
 else {
    Player="String_Node_Str";
  }
  registerLabel();
}

Fixed version (ground truth):
public void setConfiguration(long flags,EntityPlayerMP changer){
  unregisterLabel();
  super.setConfiguration(flags,changer);
  flags=flags >> 3;
  Label=(int)(flags & 0xFFFFl);
  if ((flags & (1 << (Buttons.PRIVATE.ordinal()))) != 0) {
    Player=changer.getDisplayName();
  }
 else {
    Player="String_Node_Str";
  }
  registerLabel();
}
Program: 22804
Project: 22804
Buggy source:
@Override public boolean onBlockActivated(World World,int X,int Y,int Z,EntityPlayer Player,int Side,float HitX,float HitY,float HitZ){
  TileEntity te=World.getTileEntity(X,Y,Z);
  if (te instanceof TileEntityCarriageDrive) {
    if (!(((TileEntityCarriageDrive)te).requiresScrewdriverToOpen && (Player.getHeldItem() == null || Player.getHeldItem().getItem() != RiMItems.ToolItemSet))) {
      if (te instanceof TileEntityCarriageTranslocator)       Player.openGui(ModRiM.instance,1,World,X,Y,Z);
 else       if (te instanceof TileEntityCarriageDirected)       Player.openGui(ModRiM.instance,2,World,X,Y,Z);
 else       Player.openGui(ModRiM.instance,0,World,X,Y,Z);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onBlockActivated(World World,int X,int Y,int Z,EntityPlayer Player,int Side,float HitX,float HitY,float HitZ){
  TileEntity te=World.getTileEntity(X,Y,Z);
  if (te instanceof TileEntityCarriageDrive && Player != null) {
    return ((TileEntityCarriageDrive)te).HandleToolUsage(Side,Player.isSneaking(),Player);
  }
  return false;
}
Program: 22805
Project: 22805
Buggy source:
@Override public void HandleToolUsage(int clickedSide,boolean sneaking){
  if (sneaking) {
    boolean sideClosedAtIMinus1=SideClosed[SideClosed.length - 1];
    for (int i=0; i < SideClosed.length; i++) {
      boolean oldSC=SideClosed[i];
      setSideClosed(i,sideClosedAtIMinus1);
      sideClosedAtIMinus1=oldSC;
    }
  }
 else {
    for (int i=0; i < SideClosed.length; i++) {
      setSideClosed(i,i != clickedSide);
    }
  }
  Propagate();
}

Fixed version (ground truth):
@Override public boolean HandleToolUsage(int clickedSide,boolean sneaking,EntityPlayer player){
  if (sneaking) {
    boolean sideClosedAtIMinus1=SideClosed[SideClosed.length - 1];
    for (int i=0; i < SideClosed.length; i++) {
      boolean oldSC=SideClosed[i];
      setSideClosed(i,sideClosedAtIMinus1);
      sideClosedAtIMinus1=oldSC;
    }
  }
 else {
    for (int i=0; i < SideClosed.length; i++) {
      setSideClosed(i,i != clickedSide);
    }
  }
  Propagate();
  return true;
}