Program: 125490
Project: 125490
Buggy source:
@Override public void download(URL url,File desc) throws Exception {
  BufferedInputStream bis=null;
  BufferedOutputStream bos=null;
  File tempFolder=null;
  try {
    TalendLibsServerManager manager=TalendLibsServerManager.getInstance();
    final NexusServerBean talendlibServer=manager.getLibrariesNexusServer();
    String mavenUri=url.toExternalForm();
    MavenArtifact parseMvnUrl=MavenUrlHelper.parseMvnUrl(mavenUri);
    if (parseMvnUrl != null) {
      String reletivePath=PomUtil.getArtifactPath(parseMvnUrl);
      String tempPath=getTmpFolderPath();
      tempFolder=new File(tempPath + File.separator + File.createTempFile("String_Node_Str","String_Node_Str").getName());
      if (tempFolder.exists()) {
        tempFolder.delete();
      }
      tempFolder.mkdirs();
      String name=parseMvnUrl.getArtifactId();
      String type=parseMvnUrl.getType();
      if (type == null || "String_Node_Str".equals(type)) {
        type=MavenConstants.PACKAGING_JAR;
      }
      name=name + "String_Node_Str" + type;
      File destination=new File(tempFolder,name);
      HttpURLConnection connection=getHttpURLConnection(talendlibServer.getServer(),talendlibServer.getRepositoryId(),reletivePath,talendlibServer.getUserName(),talendlibServer.getPassword());
      InputStream inputStream=connection.getInputStream();
      bis=new BufferedInputStream(inputStream);
      bos=new BufferedOutputStream(new FileOutputStream(destination));
      int contentLength=connection.getContentLength();
      fireDownloadStart(contentLength);
      int bytesDownloaded=0;
      byte[] buf=new byte[BUFFER_SIZE];
      int bytesRead=-1;
      while ((bytesRead=bis.read(buf)) != -1) {
        bos.write(buf,0,bytesRead);
        fireDownloadProgress(bytesRead);
        bytesDownloaded+=bytesRead;
        if (isCancel()) {
          return;
        }
      }
      bos.flush();
      bos.close();
      if (bytesDownloaded == contentLength) {
        ArtifactsDeployer deployer=new ArtifactsDeployer();
        deployer.deployToLocalMaven(destination.getAbsolutePath(),mavenUri);
      }
    }
    fireDownloadComplete();
  }
  finally {
    if (bis != null) {
      bis.close();
    }
    if (bos != null) {
      bos.close();
    }
    if (tempFolder != null) {
      FilesUtils.deleteFile(tempFolder,true);
    }
  }
}

Fixed version (ground truth):
@Override public void download(URL url,File desc) throws Exception {
  BufferedInputStream bis=null;
  BufferedOutputStream bos=null;
  File tempFolder=null;
  try {
    TalendLibsServerManager manager=TalendLibsServerManager.getInstance();
    final NexusServerBean talendlibServer=manager.getLibrariesNexusServer();
    String mavenUri=url.toExternalForm();
    MavenArtifact parseMvnUrl=MavenUrlHelper.parseMvnUrl(mavenUri);
    if (parseMvnUrl != null) {
      String reletivePath=PomUtil.getArtifactPath(parseMvnUrl);
      String tempPath=getTmpFolderPath();
      tempFolder=new File(tempPath + File.separator + File.createTempFile("String_Node_Str","String_Node_Str").getName());
      if (tempFolder.exists()) {
        tempFolder.delete();
      }
      tempFolder.mkdirs();
      String name=parseMvnUrl.getArtifactId();
      String type=parseMvnUrl.getType();
      if (type == null || "String_Node_Str".equals(type)) {
        type=MavenConstants.PACKAGING_JAR;
      }
      name=name + "String_Node_Str" + type;
      File destination=new File(tempFolder,name);
      HttpURLConnection connection=getHttpURLConnection(talendlibServer.getServer(),talendlibServer.getRepositoryId(),reletivePath,talendlibServer.getUserName(),talendlibServer.getPassword());
      InputStream inputStream=connection.getInputStream();
      bis=new BufferedInputStream(inputStream);
      bos=new BufferedOutputStream(new FileOutputStream(destination));
      int contentLength=connection.getContentLength();
      fireDownloadStart(contentLength);
      int bytesDownloaded=0;
      byte[] buf=new byte[BUFFER_SIZE];
      int bytesRead=-1;
      while ((bytesRead=bis.read(buf)) != -1) {
        bos.write(buf,0,bytesRead);
        fireDownloadProgress(bytesRead);
        bytesDownloaded+=bytesRead;
        if (isCancel()) {
          return;
        }
      }
      bos.flush();
      bos.close();
      if (bytesDownloaded == contentLength) {
        ArtifactsDeployer deployer=new ArtifactsDeployer();
        deployer.deployToLocalMaven(destination.getAbsolutePath(),mavenUri);
        final Map<String,ELibraryInstallStatus> statusMap=ModuleStatusProvider.getStatusMap();
        statusMap.put(mavenUri,ELibraryInstallStatus.INSTALLED);
        ModuleStatusProvider.getDeployStatusMap().put(mavenUri,ELibraryInstallStatus.DEPLOYED);
      }
    }
    fireDownloadComplete();
  }
  finally {
    if (bis != null) {
      bis.close();
    }
    if (bos != null) {
      bos.close();
    }
    if (tempFolder != null) {
      FilesUtils.deleteFile(tempFolder,true);
    }
  }
}