Program: 22766
Project: 22766
Buggy source:
/** 
 * Apply classifier to test data
 */
public void applyClassifierToTestData(){
  File[] imageFiles;
  String storeDir="String_Node_Str";
  JFileChooser fileChooser=new JFileChooser("String_Node_Str");
  fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  fileChooser.setMultiSelectionEnabled(true);
  int returnVal=fileChooser.showOpenDialog(null);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    imageFiles=fileChooser.getSelectedFiles();
  }
 else {
    return;
  }
  boolean showResults=true;
  boolean storeResults=false;
  if (imageFiles.length >= 3) {
    int decision=JOptionPane.showConfirmDialog(null,"String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.YES_NO_OPTION);
    if (decision == JOptionPane.YES_OPTION) {
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fileChooser.setMultiSelectionEnabled(false);
      returnVal=fileChooser.showOpenDialog(null);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        storeDir=fileChooser.getSelectedFile().getPath();
      }
 else {
        return;
      }
      showResults=false;
      storeResults=true;
    }
  }
  final boolean probabilityMaps;
  int decision=JOptionPane.showConfirmDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.YES_NO_OPTION);
  if (decision == JOptionPane.YES_OPTION)   probabilityMaps=true;
 else   probabilityMaps=false;
  final int numProcessors=Runtime.getRuntime().availableProcessors();
  final int numFurtherThreads=numProcessors / imageFiles.length;
  IJ.log("String_Node_Str" + imageFiles.length + "String_Node_Str"+ numProcessors+ "String_Node_Str");
  setButtonsEnabled(false);
  Thread[] threads=new Thread[numProcessors];
class ImageProcessingThread extends Thread {
    final int numThread;
    final int numProcessors;
    final File[] imageFiles;
    final boolean storeResults;
    final boolean showResults;
    final String storeDir;
    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;
    }
    public void run(){
      for (int i=numThread; i < imageFiles.length; i+=numProcessors) {
        File file=imageFiles[i];
        ImagePlus testImage=IJ.openImage(file.getPath());
        IJ.log("String_Node_Str" + file.getName() + "String_Node_Str"+ numThread);
        ImagePlus segmentation=wekaSegmentation.applyClassifier(testImage,numFurtherThreads,probabilityMaps);
        if (showResults) {
          segmentation.show();
          testImage.show();
        }
        if (storeResults) {
          String filename=storeDir + File.separator + file.getName();
          IJ.log("String_Node_Str" + filename);
          IJ.save(segmentation,filename);
          segmentation.close();
          testImage.close();
        }
      }
    }
  }
  for (int i=0; i < numProcessors; i++) {
    threads[i]=new ImageProcessingThread(i,numProcessors,imageFiles,storeResults,showResults,storeDir);
    threads[i].start();
  }
  for (  Thread thread : threads) {
    try {
      thread.join();
    }
 catch (    InterruptedException e) {
    }
  }
  updateButtonsEnabling();
}

Fixed version (ground truth):
/** 
 * Apply classifier to test data
 */
public void applyClassifierToTestData(){
  File[] imageFiles;
  String storeDir="String_Node_Str";
  JFileChooser fileChooser=new JFileChooser("String_Node_Str");
  fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  fileChooser.setMultiSelectionEnabled(true);
  int returnVal=fileChooser.showOpenDialog(null);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    imageFiles=fileChooser.getSelectedFiles();
  }
 else {
    return;
  }
  boolean showResults=true;
  boolean storeResults=false;
  if (imageFiles.length >= 3) {
    int decision=JOptionPane.showConfirmDialog(null,"String_Node_Str" + "String_Node_Str","String_Node_Str",JOptionPane.YES_NO_OPTION);
    if (decision == JOptionPane.YES_OPTION) {
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fileChooser.setMultiSelectionEnabled(false);
      returnVal=fileChooser.showOpenDialog(null);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        storeDir=fileChooser.getSelectedFile().getPath();
      }
 else {
        return;
      }
      showResults=false;
      storeResults=true;
    }
  }
  final boolean probabilityMaps;
  int decision=JOptionPane.showConfirmDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.YES_NO_OPTION);
  if (decision == JOptionPane.YES_OPTION)   probabilityMaps=true;
 else   probabilityMaps=false;
  final int numProcessors=Runtime.getRuntime().availableProcessors();
  final int numThreads=Math.min(imageFiles.length,numProcessors);
  final int numFurtherThreads=(int)Math.ceil((double)(numProcessors - numThreads) / imageFiles.length) + 1;
  IJ.log("String_Node_Str" + imageFiles.length + "String_Node_Str"+ numThreads+ "String_Node_Str");
  setButtonsEnabled(false);
  Thread[] threads=new Thread[numThreads];
class ImageProcessingThread extends Thread {
    final int numThread;
    final int numProcessors;
    final File[] imageFiles;
    final boolean storeResults;
    final boolean showResults;
    final String storeDir;
    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;
    }
    public void run(){
      for (int i=numThread; i < imageFiles.length; i+=numProcessors) {
        File file=imageFiles[i];
        ImagePlus testImage=IJ.openImage(file.getPath());
        IJ.log("String_Node_Str" + file.getName() + "String_Node_Str"+ numThread);
        ImagePlus segmentation=wekaSegmentation.applyClassifier(testImage,numFurtherThreads,probabilityMaps);
        if (showResults) {
          segmentation.show();
          testImage.show();
        }
        if (storeResults) {
          String filename=storeDir + File.separator + file.getName();
          IJ.log("String_Node_Str" + filename);
          IJ.save(segmentation,filename);
          segmentation.close();
          testImage.close();
        }
      }
    }
  }
  for (int i=0; i < numProcessors; i++) {
    threads[i]=new ImageProcessingThread(i,numProcessors,imageFiles,storeResults,showResults,storeDir);
    threads[i].start();
  }
  for (  Thread thread : threads) {
    try {
      thread.join();
    }
 catch (    InterruptedException e) {
    }
  }
  updateButtonsEnabling();
}