Program: 126253
Project: 126253
Buggy source:
/** 
 * DOC Talend Comment method "getLibrariesNexusServer". get nexus server for libraries
 * @param createTalendIfCustomNotExsit , true : if custom libraries nexus server not configured in tac , return thedefault one. false : if custom libraries nexus server not configured in tac , return null.
 * @return
 */
public static NexusServerBean getLibrariesNexusServer(boolean createTalendIfCustomNotExsit){
  try {
    IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    if (factory.getRepositoryContext() != null && factory.getRepositoryContext().getFields() != null) {
      String adminUrl=factory.getRepositoryContext().getFields().get(RepositoryConstants.REPOSITORY_URL);
      String userName="String_Node_Str";
      String password="String_Node_Str";
      User user=factory.getRepositoryContext().getUser();
      if (user != null) {
        userName=user.getLogin();
        password=new String(user.getPassword());
      }
      NexusServerBean serverBean=null;
      if (adminUrl != null && !"String_Node_Str".equals(adminUrl) && GlobalServiceRegister.getDefault().isServiceRegistered(IRemoteService.class)) {
        serverBean=new NexusServerBean();
        IRemoteService remoteService=(IRemoteService)GlobalServiceRegister.getDefault().getService(IRemoteService.class);
        JSONObject updateRepositoryUrl;
        updateRepositoryUrl=remoteService.getLibLocation(userName,password,adminUrl);
        String nexus_url=updateRepositoryUrl.getString(KEY_LIB_RUL);
        String nexus_user=updateRepositoryUrl.getString(KEY_LIB_USER);
        String nexus_pass=updateRepositoryUrl.getString(KEY_LIB_PASS);
        String url=nexus_url;
        if (url.endsWith(NexusConstants.SLASH)) {
          url=url.substring(0,url.length() - 1);
        }
        if (!nexus_url.endsWith(NexusConstants.SLASH)) {
          nexus_url=nexus_url + NexusConstants.SLASH;
        }
        serverBean.setRepositoryUrl(nexus_url);
        String server=url.substring(0,url.indexOf(NexusConstants.CONTENT_REPOSITORIES));
        String repositoryId=url.substring(url.indexOf(NexusConstants.CONTENT_REPOSITORIES) + NexusConstants.CONTENT_REPOSITORIES.length(),url.length());
        serverBean.setServer(server);
        serverBean.setUserName(nexus_user);
        serverBean.setPassword(nexus_pass);
        serverBean.setRepositoryId(repositoryId);
      }
      if (serverBean != null) {
        return serverBean;
      }
    }
  }
 catch (  PersistenceException e) {
    ExceptionHandler.process(e);
  }
catch (  LoginException e) {
    ExceptionHandler.process(e);
  }
catch (  JSONException e) {
    ExceptionHandler.process(e);
  }
 finally {
    if (createTalendIfCustomNotExsit) {
      NexusServerBean serverBean=new NexusServerBean(true);
      serverBean.setServer(TALEND_LIB_SERVER);
      serverBean.setUserName(TALEND_LIB_USER);
      serverBean.setPassword(TALEND_LIB_PASSWORD);
      serverBean.setRepositoryId(TALEND_LIB_REPOSITORY);
      return serverBean;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * DOC Talend Comment method "getLibrariesNexusServer". get nexus server for libraries
 * @param createTalendIfCustomNotExsit , true : if custom libraries nexus server not configured in tac , return thedefault one. false : if custom libraries nexus server not configured in tac , return null.
 * @return
 */
public static NexusServerBean getLibrariesNexusServer(boolean createTalendIfCustomNotExsit){
  try {
    IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    RepositoryContext repositoryContext=factory.getRepositoryContext();
    if (repositoryContext != null && repositoryContext.getFields() != null) {
      String adminUrl=repositoryContext.getFields().get(RepositoryConstants.REPOSITORY_URL);
      String userName="String_Node_Str";
      String password="String_Node_Str";
      User user=repositoryContext.getUser();
      if (user != null) {
        userName=user.getLogin();
        password=repositoryContext.getClearPassword();
      }
      NexusServerBean serverBean=null;
      serverBean=getSoftwareUpdateNexusServer(adminUrl,userName,password);
      if (serverBean != null) {
        return serverBean;
      }
    }
  }
  finally {
    if (createTalendIfCustomNotExsit) {
      NexusServerBean serverBean=new NexusServerBean(true);
      serverBean.setServer(TALEND_LIB_SERVER);
      serverBean.setUserName(TALEND_LIB_USER);
      serverBean.setPassword(TALEND_LIB_PASSWORD);
      serverBean.setRepositoryId(TALEND_LIB_REPOSITORY);
      return serverBean;
    }
  }
  return null;
}