Program: 117965
Project: 117965
Buggy source:
protected void installNewCFComponents(){
  ComponentsInstallComponent component=LocalComponentInstallHelper.getComponent();
  if (component != null) {
    File workFolder=FileUtils.createTmpFolder("String_Node_Str","String_Node_Str");
    Map<File,Long> copiedFiles=new HashMap<File,Long>();
    Map<File,String> duplicatedNameFiles=new HashMap<File,String>();
    try {
      if (needInstalledNewCFComponents != null) {
        final Iterator keys=needInstalledNewCFComponents.keys();
        while (keys.hasNext()) {
          String projectName=keys.next().toString();
          if (needInstalledNewCFComponents.has(projectName)) {
            try {
              JSONArray jsonArray=needInstalledNewCFComponents.getJSONArray(projectName);
              for (int i=0; i < jsonArray.length(); i++) {
                final String compZipPath=jsonArray.get(i).toString();
                final File compZipFile=new File(compZipPath);
                if (compZipFile.exists()) {
                  final long checksumAlder32=org.talend.utils.io.FilesUtils.getChecksumAlder32(compZipFile);
                  boolean needCopy=true;
                  File workZipFile=new File(workFolder,compZipFile.getName());
                  if (copiedFiles.containsKey(workZipFile)) {
                    final Long checksum=copiedFiles.get(workZipFile);
                    if (checksumAlder32 != checksum) {
                      workZipFile=new File(workFolder,System.currentTimeMillis() + compZipFile.getName());
                      duplicatedNameFiles.put(workZipFile,compZipFile.getName());
                    }
 else {
                      needCopy=false;
                    }
                  }
                  if (needCopy) {
                    org.talend.utils.io.FilesUtils.copyFile(compZipFile,workZipFile);
                    copiedFiles.put(workZipFile,checksumAlder32);
                  }
                }
              }
            }
 catch (            JSONException e) {
              ExceptionHandler.process(e);
            }
catch (            IOException e) {
              ExceptionHandler.process(e);
            }
          }
        }
      }
      if (copiedFiles.isEmpty()) {
        return;
      }
      try {
        component.setComponentFolder(workFolder);
        if (component.install()) {
          if (component.needRelaunch()) {
            final String message="String_Node_Str" + component.getInstalledMessages() + "String_Node_Str";
            if (!CommonUIPlugin.isFullyHeadless()) {
              boolean confirm=MessageDialog.openConfirm(null,"String_Node_Str",message);
              if (confirm && Workbench.getInstance() != null) {
                PlatformUI.getWorkbench().restart();
              }
            }
            log.warn(message);
          }
        }
 else {
          return;
        }
      }
  finally {
        component.setComponentFolder(null);
      }
      final List<File> failedComponents=component.getFailedComponents();
      List<File> doneFiles=new ArrayList<File>(copiedFiles.keySet());
      doneFiles.removeAll(failedComponents);
      try {
        if (!doneFiles.isEmpty()) {
          final IPreferenceStore preferenceStore=CodeGeneratorActivator.getDefault().getPreferenceStore();
          String installedComponentsValues=preferenceStore.getString(IComponentPreferenceConstant.INSTALLED_USER_COMPONENTS);
          JSONArray installedNewCFComponentsJson=new JSONArray();
          if (StringUtils.isNotEmpty(installedComponentsValues)) {
            installedNewCFComponentsJson=new JSONArray(installedComponentsValues);
          }
          for (          File f : doneFiles) {
            String name=duplicatedNameFiles.get(f);
            if (name == null) {
              name=f.getName();
            }
            final Long checksum=copiedFiles.get(f);
            JSONObject jsonObj=new JSONObject();
            for (int i=0; i < installedNewCFComponentsJson.length(); i++) {
              final JSONObject object=installedNewCFComponentsJson.getJSONObject(i);
              if (jsonObj.has(IComponentPreferenceConstant.JSON_KEY_FILE_NAME)) {
                final String filename=jsonObj.getString(IComponentPreferenceConstant.JSON_KEY_FILE_NAME);
                if (filename.equals(name)) {
                  jsonObj=object;
                  break;
                }
              }
            }
            JSONArray jsonArray=new JSONArray();
            if (jsonObj.has(IComponentPreferenceConstant.JSON_KEY_CHECKSUM)) {
              jsonArray=jsonObj.getJSONArray(IComponentPreferenceConstant.JSON_KEY_CHECKSUM);
            }
            jsonArray.put(checksum);
          }
          preferenceStore.putValue(IComponentPreferenceConstant.INSTALLED_USER_COMPONENTS,installedNewCFComponentsJson.toString());
        }
      }
 catch (      JSONException e) {
        ExceptionHandler.process(e);
      }
      if (!failedComponents.isEmpty()) {
        StringBuffer messages=new StringBuffer(200);
        for (        File f : failedComponents) {
          String name=duplicatedNameFiles.get(f);
          if (name == null) {
            name=f.getName();
          }
          messages.append(name + ',' + ' ');
        }
        log.error("String_Node_Str" + messages);
      }
    }
  finally {
      org.talend.utils.io.FilesUtils.deleteFolder(workFolder,true);
      needInstalledNewCFComponents=new JSONObject();
    }
  }
}

Fixed version (ground truth):
protected void installNewCFComponents(){
  ComponentsInstallComponent component=LocalComponentInstallHelper.getComponent();
  if (component != null) {
    File workFolder=FileUtils.createTmpFolder("String_Node_Str","String_Node_Str");
    Map<File,Long> copiedFiles=new HashMap<File,Long>();
    Map<File,String> duplicatedNameFiles=new HashMap<File,String>();
    try {
      if (needInstalledNewCFComponents != null) {
        final Iterator keys=needInstalledNewCFComponents.keys();
        while (keys.hasNext()) {
          String projectName=keys.next().toString();
          if (needInstalledNewCFComponents.has(projectName)) {
            try {
              JSONArray jsonArray=needInstalledNewCFComponents.getJSONArray(projectName);
              for (int i=0; i < jsonArray.length(); i++) {
                final String compZipPath=jsonArray.get(i).toString();
                final File compZipFile=new File(compZipPath);
                if (compZipFile.exists()) {
                  final long checksumAlder32=org.talend.utils.io.FilesUtils.getChecksumAlder32(compZipFile);
                  boolean needCopy=true;
                  File workZipFile=new File(workFolder,compZipFile.getName());
                  if (copiedFiles.containsKey(workZipFile)) {
                    final Long checksum=copiedFiles.get(workZipFile);
                    if (checksumAlder32 != checksum) {
                      workZipFile=new File(workFolder,System.currentTimeMillis() + compZipFile.getName());
                      duplicatedNameFiles.put(workZipFile,compZipFile.getName());
                    }
 else {
                      needCopy=false;
                    }
                  }
                  if (needCopy) {
                    org.talend.utils.io.FilesUtils.copyFile(compZipFile,workZipFile);
                    copiedFiles.put(workZipFile,checksumAlder32);
                  }
                }
              }
            }
 catch (            JSONException e) {
              ExceptionHandler.process(e);
            }
catch (            IOException e) {
              ExceptionHandler.process(e);
            }
          }
        }
      }
      if (copiedFiles.isEmpty()) {
        return;
      }
      try {
        component.setComponentFolder(workFolder);
        if (component.install()) {
          if (component.needRelaunch()) {
            final String message="String_Node_Str" + component.getInstalledMessages() + "String_Node_Str";
            if (!CommonUIPlugin.isFullyHeadless()) {
              DisplayUtils.getDisplay().syncExec(new Runnable(){
                @Override public void run(){
                  boolean confirm=MessageDialog.openConfirm(null,"String_Node_Str",message);
                  if (confirm && PlatformUI.isWorkbenchRunning()) {
                    PlatformUI.getWorkbench().restart();
                  }
                }
              }
);
            }
            log.warn(message);
          }
        }
 else {
          return;
        }
      }
  finally {
        component.setComponentFolder(null);
      }
      final List<File> failedComponents=component.getFailedComponents();
      List<File> doneFiles=new ArrayList<File>(copiedFiles.keySet());
      doneFiles.removeAll(failedComponents);
      try {
        if (!doneFiles.isEmpty()) {
          final IPreferenceStore preferenceStore=CodeGeneratorActivator.getDefault().getPreferenceStore();
          String installedComponentsValues=preferenceStore.getString(IComponentPreferenceConstant.INSTALLED_USER_COMPONENTS);
          JSONArray installedNewCFComponentsJson=new JSONArray();
          if (StringUtils.isNotEmpty(installedComponentsValues)) {
            installedNewCFComponentsJson=new JSONArray(installedComponentsValues);
          }
          for (          File f : doneFiles) {
            String name=duplicatedNameFiles.get(f);
            if (name == null) {
              name=f.getName();
            }
            final Long checksum=copiedFiles.get(f);
            JSONObject jsonObj=new JSONObject();
            for (int i=0; i < installedNewCFComponentsJson.length(); i++) {
              final JSONObject object=installedNewCFComponentsJson.getJSONObject(i);
              if (jsonObj.has(IComponentPreferenceConstant.JSON_KEY_FILE_NAME)) {
                final String filename=jsonObj.getString(IComponentPreferenceConstant.JSON_KEY_FILE_NAME);
                if (filename.equals(name)) {
                  jsonObj=object;
                  break;
                }
              }
            }
            JSONArray jsonArray=new JSONArray();
            if (jsonObj.has(IComponentPreferenceConstant.JSON_KEY_CHECKSUM)) {
              jsonArray=jsonObj.getJSONArray(IComponentPreferenceConstant.JSON_KEY_CHECKSUM);
            }
            jsonArray.put(checksum);
          }
          preferenceStore.putValue(IComponentPreferenceConstant.INSTALLED_USER_COMPONENTS,installedNewCFComponentsJson.toString());
        }
      }
 catch (      JSONException e) {
        ExceptionHandler.process(e);
      }
      if (!failedComponents.isEmpty()) {
        StringBuffer messages=new StringBuffer(200);
        for (        File f : failedComponents) {
          String name=duplicatedNameFiles.get(f);
          if (name == null) {
            name=f.getName();
          }
          messages.append(name + ',' + ' ');
        }
        log.error("String_Node_Str" + messages);
      }
    }
  finally {
      org.talend.utils.io.FilesUtils.deleteFolder(workFolder,true);
      needInstalledNewCFComponents=new JSONObject();
    }
  }
}