Program: 139730
Project: 139730
Buggy source:
/** 
 * DOC xqliu Comment method "importIndicatorToStucture".
 * @param importFile
 * @param selectionFolder
 * @param skip
 * @param rename
 */
public static void importIndicatorToStucture(File importFile,IFolder selectionFolder,boolean skip,boolean rename){
  String fileExtName=getFileExtName(importFile);
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    Set<String> names=UDIUtils.getAllIndicatorNames(selectionFolder);
    File tempFile=null, copyFile=null;
    try {
      tempFile=new File(importFile.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
      int tempCount=0;
      while (tempFile.exists() || tempCount > 100) {
        tempFile=new File(importFile.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
        tempCount++;
      }
      if (tempFile.mkdirs()) {
        FilesUtils.unzip(importFile.getAbsolutePath(),tempFile.getAbsolutePath());
        File[] listFiles=tempFile.listFiles();
        for (int i=0; i < listFiles.length; ++i) {
          File file=listFiles[i];
          String fileExt=getFileExtName(file);
          if (FactoriesUtil.UDI.equalsIgnoreCase(fileExt)) {
            String fname=DqRepositoryViewService.createFilename(file.getName(),FactoriesUtil.UDI);
            copyFile=new File(selectionFolder.getLocation().toOSString() + "String_Node_Str" + fname);
            FilesUtils.copyFile(file,copyFile);
            if (copyFile.exists()) {
              IndicatorDefinition id=UDIResourceFileHelper.getInstance().findUDI(selectionFolder.getFile(fname));
              String name=id.getName();
              if (names.contains(name)) {
                if (skip) {
                  deleteFiles(copyFile);
                  continue;
                }
                if (rename) {
                  java.text.SimpleDateFormat simpleDateFormat=new java.text.SimpleDateFormat("String_Node_Str");
                  name+="String_Node_Str" + simpleDateFormat.format(new Date()) + Math.random()+ "String_Node_Str";
                  id.setName(name);
                  names.add(name);
                }
              }
              UDIndicatorWriter.getInstance().createUDIndicatorFile(id,selectionFolder);
              deleteFiles(copyFile);
            }
          }
        }
        deleteFiles(tempFile);
      }
    }
 catch (    Exception e) {
      deleteFiles(copyFile,tempFile);
      log.error(e,e);
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "importIndicatorToStucture".
 * @param importFile
 * @param selectionFolder
 * @param skip
 * @param rename
 */
public static void importIndicatorToStucture(File importFile,IFolder selectionFolder,boolean skip,boolean rename){
  String fileExtName=getFileExtName(importFile);
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    Set<String> names=UDIUtils.getAllIndicatorNames(selectionFolder);
    File tempFile=null, copyFile=null;
    try {
      tempFile=new File(importFile.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
      int tempCount=0;
      while (tempFile.exists() || tempCount > 100) {
        tempFile=new File(importFile.getAbsolutePath() + "String_Node_Str" + System.currentTimeMillis());
        tempCount++;
      }
      if (tempFile.mkdirs()) {
        FilesUtils.unzip(importFile.getAbsolutePath(),tempFile.getAbsolutePath());
        File[] listFiles=tempFile.listFiles();
        for (int i=0; i < listFiles.length; ++i) {
          File file=listFiles[i];
          String fileExt=getFileExtName(file);
          if (FactoriesUtil.UDI.equalsIgnoreCase(fileExt)) {
            String fname=DqRepositoryViewService.createFilename(file.getName(),FactoriesUtil.UDI);
            copyFile=new File(selectionFolder.getLocation().toOSString() + "String_Node_Str" + fname);
            FilesUtils.copyFile(file,copyFile);
            if (copyFile.exists()) {
              IndicatorDefinition id=UDIResourceFileHelper.getInstance().findUDI(selectionFolder.getFile(fname));
              String name=id.getName();
              if (names.contains(name)) {
                if (skip) {
                  deleteFiles(copyFile);
                  continue;
                }
                if (rename) {
                  java.text.SimpleDateFormat simpleDateFormat=new java.text.SimpleDateFormat("String_Node_Str");
                  name+="String_Node_Str" + simpleDateFormat.format(new Date()) + Math.random()+ "String_Node_Str";
                  id.setName(name);
                }
              }
              UDIndicatorWriter.getInstance().createUDIndicatorFile(id,selectionFolder);
              deleteFiles(copyFile);
              names.add(name);
            }
          }
        }
        deleteFiles(tempFile);
      }
    }
 catch (    Exception e) {
      deleteFiles(copyFile,tempFile);
      log.error(e,e);
    }
  }
}