Program: 125302
Project: 125302
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.getTalentArtifactServer();
    String mavenUri=url.toExternalForm();
    MavenArtifact parseMvnUrl=MavenUrlHelper.parseMvnUrl(mavenUri);
    if (parseMvnUrl != null) {
      String reletivePath=PomUtil.getArtifactPath(parseMvnUrl);
      String tempPath=getTmpFolderPath();
      File createTempFile=File.createTempFile("String_Node_Str","String_Node_Str");
      createTempFile.delete();
      tempFolder=new File(tempPath + File.separator + createTempFile.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 downloadedFile=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(downloadedFile));
      int contentLength=connection.getContentLength();
      fireDownloadStart(contentLength);
      int refreshInterval=1000;
      if (contentLength < BUFFER_SIZE * 10) {
        refreshInterval=contentLength / 200;
      }
      int bytesDownloaded=0;
      byte[] buf=new byte[BUFFER_SIZE];
      int bytesRead=-1;
      long startTime=new Date().getTime();
      int byteReadInloop=0;
      while ((bytesRead=bis.read(buf)) != -1) {
        bos.write(buf,0,bytesRead);
        long currentTime=new Date().getTime();
        byteReadInloop=byteReadInloop + bytesRead;
        if (currentTime - startTime > refreshInterval) {
          startTime=currentTime;
          fireDownloadProgress(byteReadInloop);
          byteReadInloop=0;
        }
        bytesDownloaded+=bytesRead;
        if (isCancel()) {
          return;
        }
      }
      bos.flush();
      if (bytesDownloaded == contentLength) {
        MavenArtifactsHandler deployer=new MavenArtifactsHandler();
        deployer.install(downloadedFile.getAbsolutePath(),mavenUri);
        if (PluginChecker.isSVNProviderPluginLoaded()) {
          File libFile=new File(LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA));
          ISVNProviderServiceInCoreRuntime service=(ISVNProviderServiceInCoreRuntime)GlobalServiceRegister.getDefault().getService(ISVNProviderServiceInCoreRuntime.class);
          if (service != null && service.isSvnLibSetupOnTAC() && service.isInSvn(libFile.getAbsolutePath())) {
            File target=new File(libFile.getAbsolutePath(),downloadedFile.getName());
            FilesUtils.copyFile(downloadedFile,target);
            boolean localConnectionProvider=true;
            IProxyRepositoryFactory proxyRepositoryFactory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
            if (proxyRepositoryFactory != null) {
              try {
                localConnectionProvider=proxyRepositoryFactory.isLocalConnectionProvider();
              }
 catch (              PersistenceException e) {
              }
            }
            if (!localConnectionProvider && !getRepositoryContext().isOffline()) {
              List jars=new ArrayList();
              jars.add(target.getAbsolutePath());
              service.deployNewJar(jars);
            }
          }
        }
      }
    }
    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 {
  TalendLibsServerManager manager=TalendLibsServerManager.getInstance();
  final NexusServerBean talendlibServer=manager.getTalentArtifactServer();
  String mavenUri=url.toExternalForm();
  MavenArtifact parseMvnUrl=MavenUrlHelper.parseMvnUrl(mavenUri);
  if (parseMvnUrl != null) {
    String tempPath=getTmpFolderPath();
    File createTempFile=File.createTempFile("String_Node_Str","String_Node_Str");
    createTempFile.delete();
    File tempFolder=new File(tempPath + File.separator + createTempFile.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 downloadedFile=new File(tempFolder,name);
    NullProgressMonitor monitor=new NullProgressMonitor();
    new HttpClientTransport(talendlibServer.getRepositoryURI(),talendlibServer.getUserName(),talendlibServer.getPassword()){
      @Override protected HttpResponse execute(      IProgressMonitor monitor,      DefaultHttpClient httpClient,      URI targetURI) throws Exception {
        HttpGet httpGet=new HttpGet(targetURI);
        HttpResponse response=httpClient.execute(httpGet);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
          HttpEntity entity=response.getEntity();
          InputStream inputStream=entity.getContent();
          BufferedInputStream bis=null;
          BufferedOutputStream bos=null;
          try {
            bis=new BufferedInputStream(inputStream);
            bos=new BufferedOutputStream(new FileOutputStream(downloadedFile));
            long contentLength=entity.getContentLength();
            fireDownloadStart(new Long(contentLength).intValue());
            long refreshInterval=1000;
            if (contentLength < BUFFER_SIZE * 10) {
              refreshInterval=contentLength / 200;
            }
            int bytesDownloaded=0;
            byte[] buf=new byte[BUFFER_SIZE];
            int bytesRead=-1;
            long startTime=new Date().getTime();
            int byteReadInloop=0;
            while ((bytesRead=bis.read(buf)) != -1) {
              bos.write(buf,0,bytesRead);
              long currentTime=new Date().getTime();
              byteReadInloop=byteReadInloop + bytesRead;
              if (currentTime - startTime > refreshInterval) {
                startTime=currentTime;
                fireDownloadProgress(byteReadInloop);
                byteReadInloop=0;
              }
              bytesDownloaded+=bytesRead;
              if (isCancel()) {
                return response;
              }
            }
            bos.flush();
            if (bytesDownloaded == contentLength) {
              MavenArtifactsHandler deployer=new MavenArtifactsHandler();
              deployer.install(downloadedFile.getAbsolutePath(),mavenUri);
              if (PluginChecker.isSVNProviderPluginLoaded()) {
                File libFile=new File(LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA));
                ISVNProviderServiceInCoreRuntime service=(ISVNProviderServiceInCoreRuntime)GlobalServiceRegister.getDefault().getService(ISVNProviderServiceInCoreRuntime.class);
                if (service != null && service.isSvnLibSetupOnTAC() && service.isInSvn(libFile.getAbsolutePath())) {
                  File target=new File(libFile.getAbsolutePath(),downloadedFile.getName());
                  FilesUtils.copyFile(downloadedFile,target);
                  boolean localConnectionProvider=true;
                  IProxyRepositoryFactory proxyRepositoryFactory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
                  if (proxyRepositoryFactory != null) {
                    try {
                      localConnectionProvider=proxyRepositoryFactory.isLocalConnectionProvider();
                    }
 catch (                    PersistenceException e) {
                    }
                  }
                  if (!localConnectionProvider && !getRepositoryContext().isOffline()) {
                    List jars=new ArrayList();
                    jars.add(target.getAbsolutePath());
                    service.deployNewJar(jars);
                  }
                }
              }
            }
            fireDownloadComplete();
          }
  finally {
            if (bis != null) {
              bis.close();
            }
            if (bos != null) {
              bos.close();
            }
            if (tempFolder != null) {
              FilesUtils.deleteFile(tempFolder,true);
            }
          }
        }
        return response;
      }
    }
.doRequest(monitor,parseMvnUrl);
  }
}