Program: 125683
Project: 125683
Buggy source:
public IStatus shareLibs(Job job,IProgressMonitor monitor){
  ArtifactsDeployer deployer=new ArtifactsDeployer();
  Map<ModuleNeeded,File> filesToShare=null;
  IStatus status=Status.OK_STATUS;
  try {
    if (PluginChecker.isSVNProviderPluginLoaded()) {
      IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
      ISVNProviderServiceInCoreRuntime service=(ISVNProviderServiceInCoreRuntime)GlobalServiceRegister.getDefault().getService(ISVNProviderServiceInCoreRuntime.class);
      if (service != null && service.isSvnLibSetupOnTAC()) {
        if (!factory.isLocalConnectionProvider() && factory.getRepositoryContext() != null && !factory.getRepositoryContext().isOffline()) {
          service.syncLibs(monitor);
          setJobName(job,Messages.getString("String_Node_Str",TYPE_SVN));
          int shareLimit=5;
          int limit=shareLimit;
          filesToShare=getFilesToShare(monitor);
          if (filesToShare == null) {
            return Status.CANCEL_STATUS;
          }
          SubMonitor mainSubMonitor=SubMonitor.convert(monitor,filesToShare.size());
          Iterator<ModuleNeeded> iterator=filesToShare.keySet().iterator();
          int index=0;
          while (iterator.hasNext()) {
            if (monitor.isCanceled()) {
              return Status.CANCEL_STATUS;
            }
            List<String> jars=new ArrayList<String>();
            String jarName="String_Node_Str";
            while (index < limit && index < filesToShare.size()) {
              ModuleNeeded next=iterator.next();
              File file=filesToShare.get(next);
              String installLocation=getStorageDirectory().getAbsolutePath();
              File target=new File(installLocation,next.getModuleName());
              if (!target.exists()) {
                FilesUtils.copyFile(file,target);
                jars.add(target.getAbsolutePath());
                deployToLocalMaven(deployer,file,next);
                jarName+=next.getModuleName();
                if (index < limit - 1) {
                  jarName+="String_Node_Str";
                }
              }
              index++;
            }
            limit+=shareLimit;
            try {
              if (jars.size() > 0) {
                mainSubMonitor.setTaskName(Messages.getString("String_Node_Str",jarName));
                service.deployNewJar(jars);
              }
              mainSubMonitor.worked(limit);
            }
 catch (            Exception e) {
              ExceptionHandler.process(new Exception("String_Node_Str" + jarName + "String_Node_Str",e));
              status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,"String_Node_Str" + jarName + "String_Node_Str",e);
              continue;
            }
          }
        }
      }
 else {
        int searchLimit=50;
        setJobName(job,Messages.getString("String_Node_Str",TYPE_NEXUS));
        final List<MavenArtifact> searchResults=new ArrayList<MavenArtifact>();
        TalendLibsServerManager instance=TalendLibsServerManager.getInstance();
        NexusServerBean customServer=instance.getCustomNexusServer();
        if (customServer != null && customServer.getUserName() != null) {
          filesToShare=getFilesToShare(monitor);
          if (filesToShare == null) {
            return Status.CANCEL_STATUS;
          }
          SubMonitor mainSubMonitor=SubMonitor.convert(monitor,filesToShare.size());
          Set<String> groupIds=new HashSet<String>();
          for (          ModuleNeeded module : filesToShare.keySet()) {
            if (module.getMavenUri() != null) {
              MavenArtifact parseMvnUrl=MavenUrlHelper.parseMvnUrl(module.getMavenUri());
              if (parseMvnUrl != null) {
                groupIds.add(parseMvnUrl.getGroupId());
              }
            }
          }
          for (          String groupId : groupIds) {
            searchResults.addAll(instance.search(customServer.getServer(),customServer.getUserName(),customServer.getPassword(),customServer.getRepositoryId(),groupId,null,null));
            searchResults.addAll(instance.search(customServer.getServer(),customServer.getUserName(),customServer.getPassword(),customServer.getSnapshotRepId(),groupId,null,null));
          }
          int limit=searchLimit;
          int shareIndex=0;
          Iterator<ModuleNeeded> iterator=filesToShare.keySet().iterator();
          while (iterator.hasNext()) {
            if (monitor.isCanceled()) {
              return Status.CANCEL_STATUS;
            }
            shareIndex++;
            if (shareIndex == limit) {
              limit+=searchLimit;
            }
            ModuleNeeded next=iterator.next();
            File file=filesToShare.get(next);
            String pomPath=file.getParent();
            String name=file.getName();
            MavenArtifact artifact=MavenUrlHelper.parseMvnUrl(next.getMavenUri(true));
            if (artifact == null) {
              continue;
            }
            boolean eixst=false;
            for (            MavenArtifact remoteAtifact : searchResults) {
              String groupId=artifact.getGroupId();
              String artifactId=artifact.getArtifactId();
              String version=artifact.getVersion();
              String rGroup=remoteAtifact.getGroupId();
              String rArtifact=remoteAtifact.getArtifactId();
              String rVersion=remoteAtifact.getVersion();
              if (groupId != null && artifactId != null && version != null && groupId.equals(rGroup) && artifactId.equals(rArtifact) && version.equals(rVersion)) {
                eixst=true;
                break;
              }
            }
            if (eixst) {
              continue;
            }
            mainSubMonitor.setTaskName(Messages.getString("String_Node_Str",name));
            int indexOf=name.lastIndexOf("String_Node_Str");
            if (indexOf != -1) {
              pomPath=pomPath + "String_Node_Str" + name.substring(0,indexOf)+ "String_Node_Str"+ MavenConstants.PACKAGING_POM;
            }
            try {
              deployToLocalMaven(deployer,file,next);
              deployer.installToRemote(file,artifact,artifact.getType());
              File pomFile=new File(pomPath);
              if (pomFile.exists()) {
                deployer.installToRemote(pomFile,artifact,MavenConstants.PACKAGING_POM);
              }
              mainSubMonitor.worked(1);
            }
 catch (            Exception e) {
              ExceptionHandler.process(new Exception("String_Node_Str" + name + "String_Node_Str",e));
              status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,"String_Node_Str" + name + "String_Node_Str",e);
              continue;
            }
          }
        }
      }
    }
    if (filesToShare == null) {
      filesToShare=getFilesToShare(monitor);
      Iterator<ModuleNeeded> iterator=filesToShare.keySet().iterator();
      while (iterator.hasNext()) {
        ModuleNeeded next=iterator.next();
        File file=filesToShare.get(next);
        deployToLocalMaven(deployer,file,next);
      }
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
    status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,e.getMessage(),e);
  }
  return status;
}

Fixed version (ground truth):
public IStatus shareLibs(Job job,IProgressMonitor monitor){
  ArtifactsDeployer deployer=new ArtifactsDeployer();
  Map<ModuleNeeded,File> filesToShare=null;
  IStatus status=Status.OK_STATUS;
  try {
    if (PluginChecker.isSVNProviderPluginLoaded()) {
      IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
      ISVNProviderServiceInCoreRuntime service=(ISVNProviderServiceInCoreRuntime)GlobalServiceRegister.getDefault().getService(ISVNProviderServiceInCoreRuntime.class);
      if (service != null && service.isSvnLibSetupOnTAC()) {
        if (!factory.isLocalConnectionProvider() && factory.getRepositoryContext() != null && !factory.getRepositoryContext().isOffline()) {
          service.syncLibs(monitor);
          setJobName(job,Messages.getString("String_Node_Str",TYPE_SVN));
          int shareLimit=5;
          int limit=shareLimit;
          filesToShare=getFilesToShare(monitor);
          if (filesToShare == null) {
            return Status.CANCEL_STATUS;
          }
          SubMonitor mainSubMonitor=SubMonitor.convert(monitor,filesToShare.size());
          Iterator<ModuleNeeded> iterator=filesToShare.keySet().iterator();
          int index=0;
          while (iterator.hasNext()) {
            if (monitor.isCanceled()) {
              return Status.CANCEL_STATUS;
            }
            List<String> jars=new ArrayList<String>();
            String jarName="String_Node_Str";
            while (index < limit && index < filesToShare.size()) {
              ModuleNeeded next=iterator.next();
              File file=filesToShare.get(next);
              String installLocation=getStorageDirectory().getAbsolutePath();
              File target=new File(installLocation,next.getModuleName());
              if (!target.exists()) {
                FilesUtils.copyFile(file,target);
                jars.add(target.getAbsolutePath());
                deployToLocalMaven(deployer,file,next);
                jarName+=next.getModuleName();
                if (index < limit - 1) {
                  jarName+="String_Node_Str";
                }
              }
              index++;
            }
            limit+=shareLimit;
            try {
              if (jars.size() > 0) {
                mainSubMonitor.setTaskName(Messages.getString("String_Node_Str",jarName));
                service.deployNewJar(jars);
              }
              mainSubMonitor.worked(limit);
            }
 catch (            Exception e) {
              ExceptionHandler.process(new Exception("String_Node_Str" + jarName + "String_Node_Str",e));
              status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,"String_Node_Str" + jarName + "String_Node_Str",e);
              continue;
            }
          }
        }
      }
 else {
        int searchLimit=50;
        setJobName(job,Messages.getString("String_Node_Str",TYPE_NEXUS));
        final List<MavenArtifact> searchResults=new ArrayList<MavenArtifact>();
        TalendLibsServerManager instance=TalendLibsServerManager.getInstance();
        NexusServerBean customServer=instance.getCustomNexusServer();
        if (customServer != null && customServer.getUserName() != null) {
          filesToShare=getFilesToShare(monitor);
          if (filesToShare == null) {
            return Status.CANCEL_STATUS;
          }
          SubMonitor mainSubMonitor=SubMonitor.convert(monitor,filesToShare.size());
          Set<String> groupIds=new HashSet<String>();
          for (          ModuleNeeded module : filesToShare.keySet()) {
            if (module.getMavenUri() != null) {
              MavenArtifact parseMvnUrl=MavenUrlHelper.parseMvnUrl(module.getMavenUri());
              if (parseMvnUrl != null) {
                groupIds.add(parseMvnUrl.getGroupId());
              }
            }
          }
          for (          String groupId : groupIds) {
            searchResults.addAll(instance.search(customServer.getServer(),customServer.getUserName(),customServer.getPassword(),customServer.getRepositoryId(),groupId,null,null));
            searchResults.addAll(instance.search(customServer.getServer(),customServer.getUserName(),customServer.getPassword(),customServer.getSnapshotRepId(),groupId,null,null));
          }
          int limit=searchLimit;
          int shareIndex=0;
          Iterator<ModuleNeeded> iterator=filesToShare.keySet().iterator();
          while (iterator.hasNext()) {
            if (monitor.isCanceled()) {
              return Status.CANCEL_STATUS;
            }
            shareIndex++;
            if (shareIndex == limit) {
              limit+=searchLimit;
            }
            ModuleNeeded next=iterator.next();
            File file=filesToShare.get(next);
            String pomPath=file.getParent();
            String name=file.getName();
            MavenArtifact artifact=MavenUrlHelper.parseMvnUrl(next.getMavenUri(true));
            if (artifact == null) {
              continue;
            }
            int indexOf=name.lastIndexOf("String_Node_Str");
            if (indexOf != -1) {
              pomPath=pomPath + "String_Node_Str" + name.substring(0,indexOf)+ "String_Node_Str"+ MavenConstants.PACKAGING_POM;
            }
 else {
              pomPath=pomPath + name + "String_Node_Str"+ MavenConstants.PACKAGING_POM;
            }
            File pomFile=new File(pomPath);
            if (!pomFile.exists()) {
              File generatedPom=new File(PomUtil.generatePom(artifact));
              FilesUtils.copyFile(generatedPom,pomFile);
            }
            boolean eixst=false;
            for (            MavenArtifact remoteAtifact : searchResults) {
              String groupId=artifact.getGroupId();
              String artifactId=artifact.getArtifactId();
              String version=artifact.getVersion();
              String rGroup=remoteAtifact.getGroupId();
              String rArtifact=remoteAtifact.getArtifactId();
              String rVersion=remoteAtifact.getVersion();
              if (groupId != null && artifactId != null && version != null && groupId.equals(rGroup) && artifactId.equals(rArtifact) && version.equals(rVersion)) {
                eixst=true;
                break;
              }
            }
            if (eixst) {
              continue;
            }
            mainSubMonitor.setTaskName(Messages.getString("String_Node_Str",name));
            try {
              deployToLocalMaven(deployer,file,next);
              deployer.installToRemote(file,artifact,artifact.getType());
              deployer.installToRemote(pomFile,artifact,MavenConstants.PACKAGING_POM);
              mainSubMonitor.worked(1);
            }
 catch (            Exception e) {
              ExceptionHandler.process(new Exception("String_Node_Str" + name + "String_Node_Str",e));
              status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,"String_Node_Str" + name + "String_Node_Str",e);
              continue;
            }
          }
        }
      }
    }
    if (filesToShare == null) {
      filesToShare=getFilesToShare(monitor);
      Iterator<ModuleNeeded> iterator=filesToShare.keySet().iterator();
      while (iterator.hasNext()) {
        ModuleNeeded next=iterator.next();
        File file=filesToShare.get(next);
        deployToLocalMaven(deployer,file,next);
      }
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
    status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,e.getMessage(),e);
  }
  return status;
}