Program: 168208
Project: 168208
Buggy source:
/** 
 * Creates a test section for Naive Bayes Classifier
 * @param parent - Parent composite
 * @param toolkit
 * @param layout - The layout to be applied on the section
 * @param title - Title for the section
 * @param description - Description for the section.
 */
private void createTestSection(final Composite parent,FormToolkit toolkit,GridLayout layout,String title,String description){
  Section section=toolkit.createSection(parent,Section.TITLE_BAR | Section.EXPANDED | Section.DESCRIPTION);
  GridDataFactory.fillDefaults().grab(true,false).span(1,1).applyTo(section);
  GridLayoutFactory.fillDefaults().numColumns(3).applyTo(section);
  section.setText(title);
  section.setDescription(description);
  ScrolledComposite sc=new ScrolledComposite(section,SWT.H_SCROLL | SWT.V_SCROLL);
  sc.setExpandHorizontal(true);
  sc.setExpandVertical(true);
  GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sc);
  Composite sectionClient=toolkit.createComposite(section);
  sc.setContent(sectionClient);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(sc);
  GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sectionClient);
  section.setClient(sectionClient);
  NlputilsFormComposite.createEmptyRow(toolkit,sectionClient);
  testOutputPath=createBrowseButton(toolkit,sectionClient,"String_Node_Str","String_Node_Str");
  Label temp1=toolkit.createLabel(sectionClient,"String_Node_Str",SWT.NONE);
  GridDataFactory.fillDefaults().grab(false,false).span(1,0).applyTo(temp1);
  Label temp2=toolkit.createLabel(sectionClient,"String_Node_Str",SWT.NONE);
  GridDataFactory.fillDefaults().grab(false,false).span(1,0).applyTo(temp2);
  Button testButton=new Button(sectionClient,SWT.PUSH);
  testButton.setText("String_Node_Str");
  testButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      final ArrayList<String> trainingDataPaths=new ArrayList<String>();
      final ArrayList<String> tempTrainingDataPaths=new ArrayList<String>();
      TreeItem trainingDataset=trainingClassPathTree.getItem(0);
      for (      TreeItem ti : trainingDataset.getItems()) {
        tempTrainingDataPaths.add(ti.getData().toString());
      }
      final ArrayList<String> tempTestingDataPaths=new ArrayList<String>();
      final ArrayList<String> testingDataPaths=new ArrayList<String>();
      TreeItem testingDataset=testingClassPathTree.getItem(0);
      for (      TreeItem ti : testingDataset.getItems()) {
        tempTestingDataPaths.add(ti.getData().toString());
      }
      final String testTrainOutputPath=testOutputPath.getText();
      Job job=new Job("String_Node_Str"){
        private boolean isPreprocessEnabled=false;
        private String pp_outputPath=null;
        @Override protected IStatus run(        IProgressMonitor monitor){
          NaiveBayesClassifier nbc=new NaiveBayesClassifier();
          Display.getDefault().syncExec(new Runnable(){
            @Override public void run(){
              isPreprocessEnabled=preprocessEnabled.getSelection();
              pp_outputPath=CommonUiActivator.getDefault().getPreferenceStore().getString("String_Node_Str");
              if (pp_outputPath.isEmpty()) {
                form.getMessageManager().addMessage("String_Node_Str","String_Node_Str",null,IMessageProvider.ERROR);
              }
 else {
                form.getMessageManager().removeMessage("String_Node_Str");
              }
              if (!isPreprocessEnabled) {
                form.getMessageManager().removeMessage("String_Node_Str");
              }
            }
          }
);
          if (isPreprocessEnabled) {
            if (pp_outputPath.isEmpty()) {
              return Status.CANCEL_STATUS;
            }
            monitor.subTask("String_Node_Str");
            try {
              preprocessTask=new Preprocess("String_Node_Str");
              for (              String dir : tempTrainingDataPaths) {
                String preprocessedDirPath=preprocessDirectory(dir);
                trainingDataPaths.add(preprocessedDirPath);
              }
              preprocessTask=new Preprocess("String_Node_Str");
              for (              String dir : tempTestingDataPaths) {
                String preprocessedDirPath=preprocessDirectory(dir);
                testingDataPaths.add(preprocessedDirPath);
              }
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
          }
 else {
            for (            String path : tempTrainingDataPaths) {
              trainingDataPaths.add(path);
            }
            for (            String path : tempTestingDataPaths) {
              testingDataPaths.add(path);
            }
          }
          long startTime=System.currentTimeMillis();
          try {
            monitor.subTask("String_Node_Str");
            nbc.train_Test(trainingDataPaths,testingDataPaths,testTrainOutputPath,false,false);
          }
 catch (          FileNotFoundException e1) {
            e1.printStackTrace();
          }
catch (          IOException e1) {
            e1.printStackTrace();
          }
catch (          EvalError e1) {
            e1.printStackTrace();
          }
          if (monitor.isCanceled()) {
            return Status.CANCEL_STATUS;
          }
          System.out.println("String_Node_Str");
          monitor.done();
          System.out.println("String_Node_Str" + (System.currentTimeMillis() - startTime) + "String_Node_Str");
          NlputilsFormComposite.updateStatusMessage(getViewSite(),"String_Node_Str",IStatus.OK);
          return Status.OK_STATUS;
        }
      }
;
      job.setUser(true);
      job.schedule();
    }
  }
);
  NlputilsFormComposite.createEmptyRow(toolkit,sectionClient);
}

Fixed version (ground truth):
/** 
 * Creates a test section for Naive Bayes Classifier
 * @param parent - Parent composite
 * @param toolkit
 * @param layout - The layout to be applied on the section
 * @param title - Title for the section
 * @param description - Description for the section.
 */
private void createTestSection(final Composite parent,FormToolkit toolkit,GridLayout layout,String title,String description){
  Section section=toolkit.createSection(parent,Section.TITLE_BAR | Section.EXPANDED | Section.DESCRIPTION);
  GridDataFactory.fillDefaults().grab(true,false).span(1,1).applyTo(section);
  GridLayoutFactory.fillDefaults().numColumns(3).applyTo(section);
  section.setText(title);
  section.setDescription(description);
  ScrolledComposite sc=new ScrolledComposite(section,SWT.H_SCROLL | SWT.V_SCROLL);
  sc.setExpandHorizontal(true);
  sc.setExpandVertical(true);
  GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sc);
  Composite sectionClient=toolkit.createComposite(section);
  sc.setContent(sectionClient);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(sc);
  GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(sectionClient);
  section.setClient(sectionClient);
  NlputilsFormComposite.createEmptyRow(toolkit,sectionClient);
  testOutputPath=createBrowseButton(toolkit,sectionClient,"String_Node_Str","String_Node_Str");
  Label temp1=toolkit.createLabel(sectionClient,"String_Node_Str",SWT.NONE);
  GridDataFactory.fillDefaults().grab(false,false).span(1,0).applyTo(temp1);
  Label temp2=toolkit.createLabel(sectionClient,"String_Node_Str",SWT.NONE);
  GridDataFactory.fillDefaults().grab(false,false).span(1,0).applyTo(temp2);
  Button testButton=new Button(sectionClient,SWT.PUSH);
  testButton.setText("String_Node_Str");
  testButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      final ArrayList<String> trainingDataPaths=new ArrayList<String>();
      final ArrayList<String> tempTrainingDataPaths=new ArrayList<String>();
      TreeItem trainingDataset=trainingClassPathTree.getItem(0);
      for (      TreeItem ti : trainingDataset.getItems()) {
        tempTrainingDataPaths.add(ti.getData().toString());
      }
      final ArrayList<String> tempTestingDataPaths=new ArrayList<String>();
      final ArrayList<String> testingDataPaths=new ArrayList<String>();
      TreeItem testingDataset=testingClassPathTree.getItem(0);
      for (      TreeItem ti : testingDataset.getItems()) {
        tempTestingDataPaths.add(ti.getData().toString());
      }
      final String testTrainOutputPath=testOutputPath.getText();
      Job job=new Job("String_Node_Str"){
        private boolean isPreprocessEnabled=false;
        private String pp_outputPath=null;
        private boolean canItProceed=false;
        @Override protected IStatus run(        IProgressMonitor monitor){
          NlputilsFormComposite.updateStatusMessage(getViewSite(),null,null);
          NaiveBayesClassifier nbc=new NaiveBayesClassifier();
          Display.getDefault().syncExec(new Runnable(){
            @Override public void run(){
              isPreprocessEnabled=preprocessEnabled.getSelection();
              pp_outputPath=CommonUiActivator.getDefault().getPreferenceStore().getString("String_Node_Str");
              if (isPreprocessEnabled && pp_outputPath.isEmpty()) {
                form.getMessageManager().addMessage("String_Node_Str","String_Node_Str",null,IMessageProvider.ERROR);
              }
 else {
                form.getMessageManager().removeMessage("String_Node_Str");
              }
              canItProceed=canItProceedTesting(tempTrainingDataPaths,tempTestingDataPaths,testTrainOutputPath);
            }
          }
);
          if (isPreprocessEnabled) {
            if (pp_outputPath.isEmpty()) {
              return Status.CANCEL_STATUS;
            }
            monitor.subTask("String_Node_Str");
            try {
              preprocessTask=new Preprocess("String_Node_Str");
              for (              String dir : tempTrainingDataPaths) {
                String preprocessedDirPath=preprocessDirectory(dir);
                trainingDataPaths.add(preprocessedDirPath);
              }
              preprocessTask=new Preprocess("String_Node_Str");
              for (              String dir : tempTestingDataPaths) {
                String preprocessedDirPath=preprocessDirectory(dir);
                testingDataPaths.add(preprocessedDirPath);
              }
            }
 catch (            IOException e) {
              return handleException(monitor,e,"String_Node_Str");
            }
catch (            Exception e) {
              return handleException(monitor,e,"String_Node_Str");
            }
          }
 else {
            for (            String path : tempTrainingDataPaths) {
              trainingDataPaths.add(path);
            }
            for (            String path : tempTestingDataPaths) {
              testingDataPaths.add(path);
            }
          }
          if (canItProceed) {
            long startTime=System.currentTimeMillis();
            try {
              monitor.subTask("String_Node_Str");
              nbc.train_Test(trainingDataPaths,testingDataPaths,testTrainOutputPath,false,false);
            }
 catch (            FileNotFoundException e1) {
              return handleException(monitor,e1,"String_Node_Str");
            }
catch (            IOException e1) {
              return handleException(monitor,e1,"String_Node_Str");
            }
catch (            EvalError e1) {
              return handleException(monitor,e1,"String_Node_Str");
            }
catch (            Exception e) {
              return handleException(monitor,e,"String_Node_Str");
            }
            if (monitor.isCanceled()) {
              return Status.CANCEL_STATUS;
            }
            System.out.println("String_Node_Str");
            monitor.done();
            System.out.println("String_Node_Str" + (System.currentTimeMillis() - startTime) + "String_Node_Str");
            NlputilsFormComposite.updateStatusMessage(getViewSite(),"String_Node_Str",IStatus.OK);
            return Status.OK_STATUS;
          }
          return Status.CANCEL_STATUS;
        }
      }
;
      job.setUser(true);
      job.schedule();
    }
  }
);
  NlputilsFormComposite.createEmptyRow(toolkit,sectionClient);
}