Program: 120670
Project: 120670
Buggy source:
/** 
 * DOC smallet Comment method "logIn".
 * @param project
 * @throws Exception
 */
protected boolean logIn(final Project project){
  final ProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  ConnectionBean connBean=loginComposite.getConnection();
  final boolean needRestartForLocal=loginComposite.needRestartForLocal();
  if (connBean == null || project == null || project.getLabel() == null) {
    return false;
  }
  try {
    if (!project.getEmfProject().isLocal() && factory.isLocalConnectionProvider()) {
      List<IRepositoryFactory> rfList=RepositoryFactoryProvider.getAvailableRepositories();
      IRepositoryFactory remoteFactory=null;
      for (      IRepositoryFactory rf : rfList) {
        if (!rf.isLocalConnectionProvider()) {
          remoteFactory=rf;
          break;
        }
      }
      if (remoteFactory != null) {
        factory.setRepositoryFactoryFromProvider(remoteFactory);
        factory.getRepositoryContext().setOffline(true);
      }
    }
  }
 catch (  PersistenceException e) {
    ExceptionHandler.process(e);
  }
  PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
  prefManipulator.setLastProject(project.getTechnicalLabel());
  saveLastConnBean(connBean);
  if (PluginChecker.isExchangeSystemLoaded() && !TalendPropertiesUtil.isHideExchange()) {
    IPreferenceStore prefStore=PlatformUI.getPreferenceStore();
    boolean checkTisVersion=prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
    IBrandingService brandingService=(IBrandingService)GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
      int count=prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
      ExchangeUser exchangeUser=project.getExchangeUser();
      boolean isExchangeLogon=exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("String_Node_Str");
      boolean isUserPassRight=true;
      if (isExchangeLogon) {
        IExchangeService service=(IExchangeService)GlobalServiceRegister.getDefault().getService(IExchangeService.class);
        if (service.checkUserAndPass(exchangeUser.getUsername(),exchangeUser.getPassword()) != null) {
          isUserPassRight=false;
        }
      }
      if (!isExchangeLogon || !isUserPassRight) {
        if (count < 10) {
          if (Platform.getOS().equals(Platform.OS_WIN32)) {
            new Thread(){
              @Override public void run(){
                Display display=new Display();
                Shell shell=new Shell(display,SWT.ON_TOP);
                TalendForgeDialog tfDialog=new TalendForgeDialog(shell,project);
                tfDialog.open();
              }
            }
.start();
          }
 else           if (Platform.getOS().equals(Platform.OS_LINUX)) {
            TalendForgeDialog tfDialog=new TalendForgeDialog(this.getShell(),project);
            tfDialog.open();
          }
 else {
            new Thread(){
              @Override public void run(){
                Display display=new Display();
                Shell shell=new Shell(display,SWT.ON_TOP);
                TalendForgeDialog tfDialog=new TalendForgeDialog(shell,project);
                tfDialog.open();
              }
            }
.start();
          }
        }
      }
    }
  }
  try {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
      final ICoreTisService service=(ICoreTisService)GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
      if (service != null) {
        if (!service.validProject(project,needRestartForLocal)) {
          LoginComposite.isRestart=true;
          return true;
        }
      }
    }
  }
 catch (  PersistenceException e) {
    e.printStackTrace();
    loginComposite.populateProjectList();
    MessageDialog.openError(getShell(),getShell().getText(),e.getMessage());
    return false;
  }
  final Shell shell=this.getShell();
  ProgressMonitorDialog dialog=new ProgressMonitorDialog(shell);
  IRunnableWithProgress runnable=new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      try {
        factory.logOnProject(project,monitor);
      }
 catch (      LoginException e) {
        throw new InvocationTargetException(e);
      }
catch (      PersistenceException e) {
        throw new InvocationTargetException(e);
      }
catch (      OperationCanceledException e) {
        throw new InterruptedException(e.getLocalizedMessage());
      }
      monitor.done();
    }
  }
;
  try {
    dialog.run(true,true,runnable);
  }
 catch (  InvocationTargetException e) {
    if (PluginChecker.isSVNProviderPluginLoaded()) {
      loginComposite.populateProjectList();
      MessageBoxExceptionHandler.process(e.getTargetException(),getShell());
    }
 else {
      loginComposite.populateTOSProjectList();
      MessageBoxExceptionHandler.process(e.getTargetException(),getShell());
    }
    return false;
  }
catch (  InterruptedException e) {
    if (PluginChecker.isSVNProviderPluginLoaded()) {
      loginComposite.populateProjectList();
    }
 else {
      loginComposite.populateTOSProjectList();
    }
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * DOC smallet Comment method "logIn".
 * @param project
 * @throws Exception
 */
protected boolean logIn(final Project project){
  final ProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  ConnectionBean connBean=loginComposite.getConnection();
  final boolean needRestartForLocal=loginComposite.needRestartForLocal();
  if (connBean == null || project == null || project.getLabel() == null) {
    return false;
  }
  try {
    if (!project.getEmfProject().isLocal() && factory.isLocalConnectionProvider()) {
      List<IRepositoryFactory> rfList=RepositoryFactoryProvider.getAvailableRepositories();
      IRepositoryFactory remoteFactory=null;
      for (      IRepositoryFactory rf : rfList) {
        if (!rf.isLocalConnectionProvider()) {
          remoteFactory=rf;
          break;
        }
      }
      if (remoteFactory != null) {
        factory.setRepositoryFactoryFromProvider(remoteFactory);
        factory.getRepositoryContext().setOffline(true);
      }
    }
  }
 catch (  PersistenceException e) {
    ExceptionHandler.process(e);
  }
  PreferenceManipulator prefManipulator=new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
  prefManipulator.setLastProject(project.getTechnicalLabel());
  saveLastConnBean(connBean);
  if (PluginChecker.isExchangeSystemLoaded() && !TalendPropertiesUtil.isHideExchange()) {
    IPreferenceStore prefStore=PlatformUI.getPreferenceStore();
    boolean checkTisVersion=prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
    IBrandingService brandingService=(IBrandingService)GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
      int count=prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
      ExchangeUser exchangeUser=project.getExchangeUser();
      boolean isExchangeLogon=exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("String_Node_Str");
      boolean isUserPassRight=true;
      if (isExchangeLogon) {
        IExchangeService service=(IExchangeService)GlobalServiceRegister.getDefault().getService(IExchangeService.class);
        if (service.checkUserAndPass(exchangeUser.getUsername(),exchangeUser.getPassword()) != null) {
          isUserPassRight=false;
        }
      }
      if (!isExchangeLogon || !isUserPassRight) {
        if (count < 10) {
          if (Platform.getOS().equals(Platform.OS_LINUX)) {
            TalendForgeDialog tfDialog=new TalendForgeDialog(this.getShell(),project);
            tfDialog.open();
          }
 else {
            new Thread(){
              @Override public void run(){
                Display display=new Display();
                Shell shell=new Shell(display,SWT.ON_TOP);
                TalendForgeDialog tfDialog=new TalendForgeDialog(shell,project);
                tfDialog.open();
              }
            }
.start();
          }
        }
      }
    }
  }
  try {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
      final ICoreTisService service=(ICoreTisService)GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
      if (service != null) {
        if (!service.validProject(project,needRestartForLocal)) {
          LoginComposite.isRestart=true;
          return true;
        }
      }
    }
  }
 catch (  PersistenceException e) {
    e.printStackTrace();
    loginComposite.populateProjectList();
    MessageDialog.openError(getShell(),getShell().getText(),e.getMessage());
    return false;
  }
  final Shell shell=this.getShell();
  ProgressMonitorDialog dialog=new ProgressMonitorDialog(shell);
  IRunnableWithProgress runnable=new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      try {
        factory.logOnProject(project,monitor);
      }
 catch (      LoginException e) {
        throw new InvocationTargetException(e);
      }
catch (      PersistenceException e) {
        throw new InvocationTargetException(e);
      }
catch (      OperationCanceledException e) {
        throw new InterruptedException(e.getLocalizedMessage());
      }
      monitor.done();
    }
  }
;
  try {
    dialog.run(true,true,runnable);
  }
 catch (  InvocationTargetException e) {
    if (PluginChecker.isSVNProviderPluginLoaded()) {
      loginComposite.populateProjectList();
      MessageBoxExceptionHandler.process(e.getTargetException(),getShell());
    }
 else {
      loginComposite.populateTOSProjectList();
      MessageBoxExceptionHandler.process(e.getTargetException(),getShell());
    }
    return false;
  }
catch (  InterruptedException e) {
    if (PluginChecker.isSVNProviderPluginLoaded()) {
      loginComposite.populateProjectList();
    }
 else {
      loginComposite.populateTOSProjectList();
    }
    return false;
  }
  return true;
}