Program: 125289
Project: 125289
Buggy source:
@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;
}

Fixed version (ground truth):
@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;
}