Program: 125260
Project: 125260
Buggy source:
public IStatus shareLibs(Job job,IProgressMonitor monitor){
  Map<ModuleNeeded,File> filesToShare=null;
  IStatus status=Status.OK_STATUS;
  IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
  ISVNProviderServiceInCoreRuntime service=null;
  boolean shareToSvn=false;
  if (GlobalServiceRegister.getDefault().isServiceRegistered(ISVNProviderServiceInCoreRuntime.class)) {
    service=(ISVNProviderServiceInCoreRuntime)GlobalServiceRegister.getDefault().getService(ISVNProviderServiceInCoreRuntime.class);
    shareToSvn=service.isSvnLibSetupOnTAC() && factory.getRepositoryContext() != null && !factory.getRepositoryContext().isOffline();
  }
  if (shareToSvn) {
    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()) {
          try {
            MavenArtifact artifact=MavenUrlHelper.parseMvnUrl(next.getMavenUri());
            if (artifact != null) {
              shareToRepository(file,artifact);
            }
            FilesUtils.copyFile(file,target);
            jars.add(target.getAbsolutePath());
            jarName+=next.getModuleName();
            if (index < limit - 1) {
              jarName+="String_Node_Str";
            }
          }
 catch (          Exception e) {
            continue;
          }
        }
        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 {
    try {
      int searchLimit=50;
      setJobName(job,Messages.getString("String_Node_Str",TYPE_NEXUS));
      final List<MavenArtifact> searchResults=new ArrayList<MavenArtifact>();
      NexusServerBean customNexusServer=TalendLibsServerManager.getInstance().getCustomNexusServer();
      IRepositoryArtifactHandler customerRepHandler=RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
      if (customerRepHandler != 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(customerRepHandler.search(groupId,null,null,true,true));
        }
        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 name=file.getName();
          MavenArtifact artifact=MavenUrlHelper.parseMvnUrl(next.getMavenUri());
          if (artifact == null) {
            continue;
          }
          boolean eixst=false;
          String groupId=artifact.getGroupId();
          String artifactId=artifact.getArtifactId();
          String version=artifact.getVersion();
          for (          MavenArtifact remoteAtifact : searchResults) {
            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 {
            shareToRepository(file,artifact);
            mainSubMonitor.worked(1);
          }
 catch (          Exception e) {
            continue;
          }
        }
      }
    }
 catch (    Exception e) {
      status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,"String_Node_Str",e);
    }
  }
  return status;
}

Fixed version (ground truth):
public IStatus shareLibs(Job job,IProgressMonitor monitor){
  Map<ModuleNeeded,File> filesToShare=null;
  IStatus status=Status.OK_STATUS;
  try {
    int searchLimit=50;
    setJobName(job,Messages.getString("String_Node_Str",TYPE_NEXUS));
    final List<MavenArtifact> searchResults=new ArrayList<MavenArtifact>();
    NexusServerBean customNexusServer=TalendLibsServerManager.getInstance().getCustomNexusServer();
    IRepositoryArtifactHandler customerRepHandler=RepositoryArtifactHandlerManager.getRepositoryHandler(customNexusServer);
    if (customerRepHandler != 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(customerRepHandler.search(groupId,null,null,true,true));
      }
      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 name=file.getName();
        MavenArtifact artifact=MavenUrlHelper.parseMvnUrl(next.getMavenUri());
        if (artifact == null) {
          continue;
        }
        boolean eixst=false;
        String groupId=artifact.getGroupId();
        String artifactId=artifact.getArtifactId();
        String version=artifact.getVersion();
        for (        MavenArtifact remoteAtifact : searchResults) {
          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 {
          shareToRepository(file,artifact);
          mainSubMonitor.worked(1);
        }
 catch (        Exception e) {
          continue;
        }
      }
    }
  }
 catch (  Exception e) {
    status=new Status(IStatus.ERROR,"String_Node_Str",IStatus.ERROR,"String_Node_Str",e);
  }
  return status;
}