Program: 11961
Project: 11961
Buggy source:
public void run(IAction action){
  store=getIPreferenceStore();
  Configuration config=getConfiguration(store,selection);
  PropertiesLoader props=getPropertiesLoader(config.language);
  String resourcePathForTestCaseFile=null;
  StructuredSelection structuredSelection=null;
  try {
    if (selection instanceof StructuredSelection) {
      structuredSelection=(StructuredSelection)selection;
    }
    if (isNotSelected(structuredSelection)) {
      openWarningForRequired(props);
      return;
    }
 else     if (isSelectedSeveral(structuredSelection)) {
      openWarningForSelectOneOnly(props);
      return;
    }
    String projectName=getProjectName(structuredSelection);
    String resourcePathForTargetClassFile=getResourcePathForTargetClassFile(structuredSelection);
    String targetClassName=getClassNameFromResourcePathForTargetClassFile(resourcePathForTargetClassFile);
    if (targetClassName == null) {
      openWarningForSelectJavaFile(props);
      return;
    }
    resourcePathForTestCaseFile=resourcePathForTargetClassFile.replace(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    String projectRootAbsolutePath=getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) + StringValue.DirectorySeparator.General + projectName+ StringValue.DirectorySeparator.General;
    String testCaseFileAbsolutePath=projectRootAbsolutePath + resourcePathForTestCaseFile;
    File testCaseIOFile=new File(testCaseFileAbsolutePath);
    if (!testCaseIOFile.exists()) {
      String testCaseFilename=getTestClassNameFromClassName(targetClassName);
      String msg=props.get(Dialog.Common.notExist) + "String_Node_Str" + testCaseFilename+ "String_Node_Str"+ StringValue.LineFeed+ props.get(Dialog.Common.confirmToCreateNewFile);
      if (testCaseFilename != null && openConfirm(props,msg)) {
        new CreateNewTestCaseAction().run(action,selection);
      }
      return;
    }
    int retryCount=0;
    IEditorPart editorPart=null;
    while (true) {
      try {
        IProject project=getIProject(projectName);
        IWorkbenchPage page=getIWorkbenchPage();
        IFile targetFile=getIFile(project,resourcePathForTargetClassFile);
        String targetFileEncoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(targetFile));
        String targetSourceCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(targetFile),targetFileEncoding);
        ClassMeta targetClassMeta=new ClassMetaExtractor(config).extract(targetSourceCodeString);
        IFile testCaseFile=getIFile(project,resourcePathForTestCaseFile);
        String testCaseFileEncoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(testCaseFile));
        String currentTestCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(testCaseFile),testCaseFileEncoding);
        String newTestCodeString=new DefaultTestCaseGenerator(config).initialize(targetClassMeta).getTestCaseSourceCodeWithLackingTestMethod(currentTestCodeString);
        OutputStreamWriter writer=null;
        FileOutputStream outputStream=null;
        try {
          outputStream=new FileOutputStream(testCaseIOFile);
          writer=new OutputStreamWriter(outputStream,getDetectedEncodingFrom(testCaseFile,config.outputFileEncoding));
          writer.write(newTestCodeString);
        }
  finally {
          IOUtil.close(writer);
          IOUtil.close(outputStream);
        }
        if (!ResourceRefreshUtil.refreshLocal(null,projectName + StringValue.DirectorySeparator.General + resourcePathForTestCaseFile+ "String_Node_Str")) {
          openWarningForResourceRefreshError(props);
          System.err.println("String_Node_Str");
          return;
        }
        retryCount=0;
        ThreadUtil.sleep(1500);
        while (true) {
          try {
            editorPart=getIEditorPart(page,testCaseFile);
            if (editorPart == null) {
              throw new NullPointerException();
            }
            break;
          }
 catch (          Exception e) {
            retryCount++;
            if (retryCount > 3) {
              break;
            }
            ThreadUtil.sleep(1500);
          }
        }
        editorPart.setFocus();
      }
 catch (      Exception e) {
        retryCount++;
        if (retryCount > 10) {
          break;
        }
        e.printStackTrace();
        ThreadUtil.sleep(1500);
      }
      break;
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(IAction action){
  store=getIPreferenceStore();
  Configuration config=getConfiguration(store,selection);
  PropertiesLoader props=getPropertiesLoader(config.language);
  String resourcePathForTestCaseFile=null;
  StructuredSelection structuredSelection=null;
  try {
    if (selection instanceof StructuredSelection) {
      structuredSelection=(StructuredSelection)selection;
    }
    if (isNotSelected(structuredSelection)) {
      openWarningForRequired(props);
      return;
    }
 else     if (isSelectedSeveral(structuredSelection)) {
      openWarningForSelectOneOnly(props);
      return;
    }
    String projectName=getProjectName(structuredSelection);
    String resourcePathForTargetClassFile=getResourcePathForTargetClassFile(structuredSelection);
    String targetClassName=getClassNameFromResourcePathForTargetClassFile(resourcePathForTargetClassFile);
    if (targetClassName == null) {
      openWarningForSelectJavaFile(props);
      return;
    }
    resourcePathForTestCaseFile=resourcePathForTargetClassFile.replace(config.directoryPathOfProductSourceCode,config.directoryPathOfTestSourceCode).replace(StringValue.FileExtension.JavaFile,StringValue.JUnit.TestClassNameSuffix + StringValue.FileExtension.JavaFile);
    String projectRootAbsolutePath=getWorkspaceRootAbsolutePath(getIWorkspaceRoot()) + StringValue.DirectorySeparator.General + projectName+ StringValue.DirectorySeparator.General;
    String testCaseFileAbsolutePath=projectRootAbsolutePath + resourcePathForTestCaseFile;
    File testCaseIOFile=new File(testCaseFileAbsolutePath);
    if (!testCaseIOFile.exists()) {
      String testCaseFilename=getTestClassNameFromClassName(targetClassName);
      String msg=props.get(Dialog.Common.notExist) + "String_Node_Str" + testCaseFilename+ "String_Node_Str"+ StringValue.LineFeed+ props.get(Dialog.Common.confirmToCreateNewFile);
      if (testCaseFilename != null && openConfirm(props,msg)) {
        new CreateNewTestCaseAction().run(action,selection);
      }
      return;
    }
    int retryCount=0;
    IEditorPart editorPart=null;
    while (true) {
      try {
        IProject project=getIProject(projectName);
        IWorkbenchPage page=getIWorkbenchPage();
        String absolutePath=projectRootAbsolutePath + StringValue.DirectorySeparator.General;
        config.directoryPathOfProductSourceCode=absolutePath + config.directoryPathOfProductSourceCode;
        config.directoryPathOfTestSourceCode=absolutePath + config.directoryPathOfTestSourceCode;
        IFile targetFile=getIFile(project,resourcePathForTargetClassFile);
        String targetFileEncoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(targetFile));
        String targetSourceCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(targetFile),targetFileEncoding);
        ClassMeta targetClassMeta=new ClassMetaExtractor(config).extract(targetSourceCodeString);
        IFile testCaseFile=getIFile(project,resourcePathForTestCaseFile);
        String testCaseFileEncoding=UniversalDetectorUtil.getDetectedEncoding(EclipseIFileUtil.getInputStreamFrom(testCaseFile));
        String currentTestCodeString=IOUtil.readAsString(EclipseIFileUtil.getInputStreamFrom(testCaseFile),testCaseFileEncoding);
        String newTestCodeString=new DefaultTestCaseGenerator(config).initialize(targetClassMeta).getTestCaseSourceCodeWithLackingTestMethod(currentTestCodeString);
        OutputStreamWriter writer=null;
        FileOutputStream outputStream=null;
        try {
          outputStream=new FileOutputStream(testCaseIOFile);
          writer=new OutputStreamWriter(outputStream,getDetectedEncodingFrom(testCaseFile,config.outputFileEncoding));
          writer.write(newTestCodeString);
        }
  finally {
          IOUtil.close(writer);
          IOUtil.close(outputStream);
        }
        if (!ResourceRefreshUtil.refreshLocal(null,projectName + StringValue.DirectorySeparator.General + resourcePathForTestCaseFile+ "String_Node_Str")) {
          openWarningForResourceRefreshError(props);
          System.err.println("String_Node_Str");
          return;
        }
        retryCount=0;
        ThreadUtil.sleep(1500);
        while (true) {
          try {
            editorPart=getIEditorPart(page,testCaseFile);
            if (editorPart == null) {
              throw new NullPointerException();
            }
            break;
          }
 catch (          Exception e) {
            retryCount++;
            if (retryCount > 3) {
              break;
            }
            ThreadUtil.sleep(1500);
          }
        }
        editorPart.setFocus();
      }
 catch (      Exception e) {
        retryCount++;
        if (retryCount > 10) {
          break;
        }
        e.printStackTrace();
        ThreadUtil.sleep(1500);
      }
      break;
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}