Program: 125220
Project: 125220
Buggy source:
/** 
 * DOC tang Comment method "logOnProject".
 * @param project
 * @param monitorWrap
 * @throws PersistenceException
 * @throws LoginException
 */
public void logOnProject(Project project,IProgressMonitor monitor) throws LoginException, PersistenceException {
  try {
    TimeMeasure.display=CommonsPlugin.isDebugMode();
    TimeMeasure.displaySteps=CommonsPlugin.isDebugMode();
    TimeMeasure.measureActive=CommonsPlugin.isDebugMode();
    TimeMeasure.begin("String_Node_Str");
    try {
      System.getProperties().put("String_Node_Str",Boolean.FALSE.toString());
      IWorkspace workspace=ResourcesPlugin.getWorkspace();
      IWorkspaceDescription description=workspace.getDescription();
      if (description.isAutoBuilding()) {
        description.setAutoBuilding(false);
        try {
          workspace.setDescription(description);
        }
 catch (        CoreException e) {
        }
      }
      isCancelled=false;
      fullLogonFinished=false;
      SubMonitor subMonitor=SubMonitor.convert(monitor,MAX_TASKS);
      SubMonitor currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      project.setReferenceProjectProvider(null);
      getRepositoryContext().setProject(null);
      initEmfProjectContent();
      if (getEmfProjectContent(project.getTechnicalLabel()) != null) {
        project.setEmfProject(getEmfProjectContent(project.getTechnicalLabel()));
      }
      getRepositoryContext().setProject(project);
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ProjectManager.getInstance().getBeforeLogonRecords().clear();
      ProjectManager.getInstance().getUpdatedRemoteHandlerRecords().clear();
      ReferenceProjectProvider.clearTacReferenceList();
      ReferenceProjectProblemManager.getInstance().clearAll();
      this.repositoryFactoryFromProvider.beforeLogon(project);
      ProjectManager.getInstance().getBeforeLogonRecords().clear();
      ProjectManager.getInstance().getUpdatedRemoteHandlerRecords().clear();
      checkReferenceProjectsProblems(project);
      if (isCancelled) {
        throw new OperationCanceledException("String_Node_Str");
      }
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      checkProjectCompatibility(project);
      if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
        IMavenUIService mavenUIService=(IMavenUIService)GlobalServiceRegister.getDefault().getService(IMavenUIService.class);
        if (mavenUIService != null) {
          mavenUIService.updateMavenResolver(true);
        }
      }
      ICoreService coreService=getCoreService();
      if (coreService != null) {
        currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
        currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
        coreService.syncLibraries(currentMonitor);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
      }
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask("String_Node_Str",1);
      ProjectManager.getInstance().getMigrationRecords().clear();
      executeMigrations(project,true,currentMonitor);
      ProjectManager.getInstance().getMigrationRecords().clear();
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ProjectManager.getInstance().getLogonRecords().clear();
      this.repositoryFactoryFromProvider.logOnProject(project);
      ProjectManager.getInstance().getLogonRecords().clear();
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      emptyTempFolder(project);
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ICoreUIService coreUiService=null;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreUIService.class)) {
        coreUiService=(ICoreUIService)GlobalServiceRegister.getDefault().getService(ICoreUIService.class);
      }
      if (coreUiService != null) {
        coreUiService.componentsReset();
      }
      fireRepositoryPropertyChange(ERepositoryActionName.PROJECT_PREFERENCES_RELOAD.getName(),null,null);
      IRunProcessService runProcessService=getRunProcessService();
      if (runProcessService != null) {
        runProcessService.initMavenJavaProject(monitor,project);
      }
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ProjectManager.getInstance().getMigrationRecords().clear();
      executeMigrations(project,false,currentMonitor);
      ProjectManager.getInstance().getMigrationRecords().clear();
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException("String_Node_Str");
      }
      if (coreService != null) {
        currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
        String specifiedVersion=null;
        String currentVersion=JavaUtils.getProjectJavaVersion();
        String newVersion=null;
        if (CommonUIPlugin.isFullyHeadless()) {
          specifiedVersion=JavaHomeUtil.getSpecifiedJavaVersion();
        }
        if (specifiedVersion == null) {
          newVersion=currentVersion != null ? currentVersion : JavaUtils.DEFAULT_VERSION;
        }
 else {
          newVersion=specifiedVersion;
        }
        JavaUtils.updateProjectJavaVersion(newVersion);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
        if (workspace instanceof Workspace) {
          ((Workspace)workspace).getFileSystemManager().getHistoryStore().clean(currentMonitor);
        }
        TimeMeasure.step("String_Node_Str","String_Node_Str");
        currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
        currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
        try {
          coreService.syncAllRoutines();
          coreService.syncAllBeans();
        }
 catch (        SystemException e1) {
        }
      }
      if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException("String_Node_Str");
      }
      if (coreUiService != null && PluginChecker.isRulesPluginLoaded()) {
        coreUiService.syncAllRules();
      }
      if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException("String_Node_Str");
      }
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      if (coreUiService != null && coreService != null) {
        coreService.syncLog4jSettings(null);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
      }
      try {
        URL url=MetadataTalendType.getProjectForderURLOfMappingsFile();
        if (url != null) {
          System.setProperty("String_Node_Str",url.toString());
        }
      }
 catch (      SystemException e) {
      }
      if (runProcessService != null) {
        runProcessService.initializeRootPoms(monitor);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
      }
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
        ITDQRepositoryService tdqRepositoryService=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
        if (tdqRepositoryService != null) {
          tdqRepositoryService.initProxyRepository();
        }
      }
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ITaCoKitService.class)) {
        ITaCoKitService tacokitService=(ITaCoKitService)GlobalServiceRegister.getDefault().getService(ITaCoKitService.class);
        try {
          tacokitService.checkMigration(monitor);
        }
 catch (        Exception e) {
          ExceptionHandler.process(e);
        }
      }
      fullLogonFinished=true;
      this.repositoryFactoryFromProvider.afterLogon(monitor);
    }
  finally {
      TimeMeasure.end("String_Node_Str");
      TimeMeasure.display=false;
      TimeMeasure.displaySteps=false;
      TimeMeasure.measureActive=false;
    }
    String str[]=new String[]{getRepositoryContext().getUser() + "String_Node_Str",projectManager.getCurrentProject() + "String_Node_Str"};
    log.info(Messages.getString("String_Node_Str",str));
  }
 catch (  LoginException e) {
    logOffProject();
    throw e;
  }
catch (  PersistenceException e) {
    logOffProject();
    throw e;
  }
catch (  BusinessException e) {
    logOffProject();
    throw new PersistenceException(e);
  }
catch (  RuntimeException e) {
    logOffProject();
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * DOC tang Comment method "logOnProject".
 * @param project
 * @param monitorWrap
 * @throws PersistenceException
 * @throws LoginException
 */
public void logOnProject(Project project,IProgressMonitor monitor) throws LoginException, PersistenceException {
  try {
    TimeMeasure.display=CommonsPlugin.isDebugMode();
    TimeMeasure.displaySteps=CommonsPlugin.isDebugMode();
    TimeMeasure.measureActive=CommonsPlugin.isDebugMode();
    TimeMeasure.begin("String_Node_Str");
    try {
      System.getProperties().put("String_Node_Str",Boolean.FALSE.toString());
      IWorkspace workspace=ResourcesPlugin.getWorkspace();
      IWorkspaceDescription description=workspace.getDescription();
      if (description.isAutoBuilding()) {
        description.setAutoBuilding(false);
        try {
          workspace.setDescription(description);
        }
 catch (        CoreException e) {
        }
      }
      isCancelled=false;
      fullLogonFinished=false;
      SubMonitor subMonitor=SubMonitor.convert(monitor,MAX_TASKS);
      SubMonitor currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      project.setReferenceProjectProvider(null);
      getRepositoryContext().setProject(null);
      initEmfProjectContent();
      if (getEmfProjectContent(project.getTechnicalLabel()) != null) {
        project.setEmfProject(getEmfProjectContent(project.getTechnicalLabel()));
      }
      getRepositoryContext().setProject(project);
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ProjectManager.getInstance().getBeforeLogonRecords().clear();
      ProjectManager.getInstance().getUpdatedRemoteHandlerRecords().clear();
      ReferenceProjectProvider.clearTacReferenceList();
      ReferenceProjectProblemManager.getInstance().clearAll();
      this.repositoryFactoryFromProvider.beforeLogon(project);
      ProjectManager.getInstance().getBeforeLogonRecords().clear();
      ProjectManager.getInstance().getUpdatedRemoteHandlerRecords().clear();
      checkReferenceProjectsProblems(project);
      if (isCancelled) {
        throw new OperationCanceledException("String_Node_Str");
      }
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      checkProjectCompatibility(project);
      if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
        IMavenUIService mavenUIService=(IMavenUIService)GlobalServiceRegister.getDefault().getService(IMavenUIService.class);
        if (mavenUIService != null) {
          mavenUIService.updateMavenResolver(true);
        }
      }
      ICoreService coreService=getCoreService();
      if (coreService != null) {
        currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
        currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
        coreService.syncLibraries(currentMonitor);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
      }
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask("String_Node_Str",1);
      ProjectManager.getInstance().getMigrationRecords().clear();
      executeMigrations(project,true,currentMonitor);
      ProjectManager.getInstance().getMigrationRecords().clear();
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ProjectManager.getInstance().getLogonRecords().clear();
      this.repositoryFactoryFromProvider.logOnProject(project);
      ProjectManager.getInstance().getLogonRecords().clear();
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      emptyTempFolder(project);
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ICoreUIService coreUiService=null;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreUIService.class)) {
        coreUiService=(ICoreUIService)GlobalServiceRegister.getDefault().getService(ICoreUIService.class);
      }
      if (coreUiService != null) {
        coreUiService.componentsReset();
      }
      fireRepositoryPropertyChange(ERepositoryActionName.PROJECT_PREFERENCES_RELOAD.getName(),null,null);
      IRunProcessService runProcessService=getRunProcessService();
      if (runProcessService != null) {
        runProcessService.initMavenJavaProject(monitor,project);
      }
      currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
      currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
      ProjectManager.getInstance().getMigrationRecords().clear();
      executeMigrations(project,false,currentMonitor);
      ProjectManager.getInstance().getMigrationRecords().clear();
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException("String_Node_Str");
      }
      boolean isCommandLineLocalRefProject=false;
      CommandLineContext commandLineContext=(CommandLineContext)CoreRuntimePlugin.getInstance().getContext().getProperty(Context.COMMANDLINE_CONTEXT_KEY);
      if (commandLineContext != null && commandLineContext.isLogonRefProject()) {
        isCommandLineLocalRefProject=true;
      }
      if (coreService != null) {
        currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
        String specifiedVersion=null;
        String currentVersion=JavaUtils.getProjectJavaVersion();
        String newVersion=null;
        if (CommonUIPlugin.isFullyHeadless()) {
          specifiedVersion=JavaHomeUtil.getSpecifiedJavaVersion();
        }
        if (specifiedVersion == null) {
          newVersion=currentVersion != null ? currentVersion : JavaUtils.DEFAULT_VERSION;
        }
 else {
          newVersion=specifiedVersion;
        }
        JavaUtils.updateProjectJavaVersion(newVersion);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
        if (workspace instanceof Workspace) {
          ((Workspace)workspace).getFileSystemManager().getHistoryStore().clean(currentMonitor);
        }
        TimeMeasure.step("String_Node_Str","String_Node_Str");
        currentMonitor=subMonitor.newChild(1,SubMonitor.SUPPRESS_NONE);
        currentMonitor.beginTask(Messages.getString("String_Node_Str"),1);
        if (!isCommandLineLocalRefProject) {
          try {
            coreService.syncAllRoutines();
            coreService.syncAllBeans();
          }
 catch (          SystemException e1) {
          }
        }
      }
      if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException("String_Node_Str");
      }
      if (coreUiService != null && PluginChecker.isRulesPluginLoaded()) {
        coreUiService.syncAllRules();
      }
      if (monitor != null && monitor.isCanceled()) {
        throw new OperationCanceledException("String_Node_Str");
      }
      TimeMeasure.step("String_Node_Str","String_Node_Str");
      if (coreUiService != null && coreService != null) {
        coreService.syncLog4jSettings(null);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
      }
      try {
        URL url=MetadataTalendType.getProjectForderURLOfMappingsFile();
        if (url != null) {
          System.setProperty("String_Node_Str",url.toString());
        }
      }
 catch (      SystemException e) {
      }
      if (runProcessService != null && !isCommandLineLocalRefProject) {
        runProcessService.initializeRootPoms(monitor);
        TimeMeasure.step("String_Node_Str","String_Node_Str");
      }
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
        ITDQRepositoryService tdqRepositoryService=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
        if (tdqRepositoryService != null) {
          tdqRepositoryService.initProxyRepository();
        }
      }
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ITaCoKitService.class)) {
        ITaCoKitService tacokitService=(ITaCoKitService)GlobalServiceRegister.getDefault().getService(ITaCoKitService.class);
        try {
          tacokitService.checkMigration(monitor);
        }
 catch (        Exception e) {
          ExceptionHandler.process(e);
        }
      }
      fullLogonFinished=true;
      this.repositoryFactoryFromProvider.afterLogon(monitor);
    }
  finally {
      TimeMeasure.end("String_Node_Str");
      TimeMeasure.display=false;
      TimeMeasure.displaySteps=false;
      TimeMeasure.measureActive=false;
    }
    String str[]=new String[]{getRepositoryContext().getUser() + "String_Node_Str",projectManager.getCurrentProject() + "String_Node_Str"};
    log.info(Messages.getString("String_Node_Str",str));
  }
 catch (  LoginException e) {
    logOffProject();
    throw e;
  }
catch (  PersistenceException e) {
    logOffProject();
    throw e;
  }
catch (  BusinessException e) {
    logOffProject();
    throw new PersistenceException(e);
  }
catch (  RuntimeException e) {
    logOffProject();
    throw e;
  }
}