Program: 125290
Project: 125290
Buggy source:
@Override public void download(URL url,File desc) throws Exception {
  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(nexusServer.getRepositoryURI(),nexusServer.getUserName(),nexusServer.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,nexusServer.isOfficial());
              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);
  }
}

Fixed version (ground truth):
@Override public void download(URL url,File desc) throws Exception {
  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();
    NexusServerBean nServer=getNexusServer();
    new HttpClientTransport(nServer.getRepositoryURI(),nServer.getUserName(),nServer.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,nServer.isOfficial());
              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);
  }
}