Program: 125619
Project: 125619
Buggy source:
@Override public void executeMigrationTasksForLogon(final Project project,final boolean beforeLogon,final IProgressMonitor monitorWrap){
  String taskDesc="String_Node_Str" + project.getLabel() + "String_Node_Str";
  log.trace(taskDesc);
  final List<IProjectMigrationTask> toExecute=GetTasksHelper.getProjectTasks(beforeLogon);
  final List<MigrationTask> done=new ArrayList<MigrationTask>(project.getEmfProject().getMigrationTask());
  if (beforeLogon) {
    boolean isNewProject=project.getEmfProject().getProductVersion() == null ? true : false;
    setMigrationOnNewProject(beforeLogon && isNewProject && done.isEmpty());
  }
  sortMigrationTasks(toExecute);
  int nbMigrationsToDo=0;
  for (  IProjectMigrationTask task : toExecute) {
    MigrationTask mgTask=MigrationUtil.findMigrationTask(done,task);
    if (mgTask == null && !task.isDeprecated()) {
      nbMigrationsToDo++;
    }
  }
  if (!beforeLogon && (!RelationshipItemBuilder.INDEX_VERSION.equals(project.getEmfProject().getItemsRelationVersion()) || nbMigrationsToDo > 0)) {
    MigrationUtil.removeMigrationTaskById(done,RELATION_TASK);
    RelationshipItemBuilder.getInstance().unloadRelations();
    nbMigrationsToDo++;
  }
  if (nbMigrationsToDo == 0) {
    return;
  }
  MigrationUtil.removeMigrationTaskById(done,"String_Node_Str");
  boolean haveAnyBinFolder=false;
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  IProject fsProject=workspace.getRoot().getProject(project.getTechnicalLabel());
  for (  ERepositoryObjectType type : (ERepositoryObjectType[])ERepositoryObjectType.values()) {
    if (!type.hasFolder()) {
      continue;
    }
    String folderName=ERepositoryObjectType.getFolderName(type);
    if (folderName == null || "String_Node_Str".equals(folderName)) {
      continue;
    }
    IFolder folder=fsProject.getFolder(folderName);
    if (folder.exists() && folder.getFolder("String_Node_Str").exists()) {
      haveAnyBinFolder=true;
      break;
    }
  }
  if (haveAnyBinFolder) {
    MigrationUtil.removeMigrationTaskById(done,"String_Node_Str");
  }
  final SubProgressMonitor subProgressMonitor=new SubProgressMonitor(monitorWrap,toExecute.size());
  IRepositoryService service=(IRepositoryService)GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
  final IProxyRepositoryFactory repFactory=service.getProxyRepositoryFactory();
  RepositoryWorkUnit repositoryWorkUnit=new RepositoryWorkUnit(project,taskDesc){
    @Override public void run() throws PersistenceException {
      final IWorkspaceRunnable op=new IWorkspaceRunnable(){
        @Override public void run(        IProgressMonitor monitor) throws CoreException {
          if (!isMigrationOnNewProject() && beforeLogon) {
            appendToLogFile(project,"String_Node_Str" + project.getLabel() + "String_Node_Str");
          }
          try {
            boolean needSave=false;
            if (!isMigrationOnNewProject()) {
              if (!beforeLogon) {
                ERepositoryObjectType[] types=(ERepositoryObjectType[])ERepositoryObjectType.values();
                Arrays.sort(types,new Comparator<ERepositoryObjectType>(){
                  @Override public int compare(                  ERepositoryObjectType arg0,                  ERepositoryObjectType arg1){
                    if (arg0 == ERepositoryObjectType.PROCESS) {
                      return 1;
                    }
                    if (arg0 == ERepositoryObjectType.JOBLET) {
                      return 1;
                    }
                    return 0;
                  }
                }
);
                for (                ERepositoryObjectType type : types) {
                  if (!type.isResourceItem()) {
                    continue;
                  }
                  List<IRepositoryViewObject> objects=repFactory.getAll(project,type,true,true);
                  for (                  IRepositoryViewObject object : objects) {
                    Item item=object.getProperty().getItem();
                    monitorWrap.subTask("String_Node_Str" + item.getProperty().getLabel());
                    boolean hadFailed=false;
                    subProgressMonitor.worked(1);
                    for (                    IProjectMigrationTask task : toExecute) {
                      if (monitorWrap.isCanceled()) {
                        throw new OperationCanceledException(Messages.getString("String_Node_Str",task.getName()));
                      }
                      MigrationTask mgTask=MigrationUtil.findMigrationTask(done,task);
                      if (mgTask == null && !task.isDeprecated()) {
                        try {
                          ExecutionResult status=task.execute(project,item);
switch (status) {
case SUCCESS_WITH_ALERT:
                            if (task.getStatus() != ExecutionResult.FAILURE) {
                              task.setStatus(status);
                            }
case SUCCESS_NO_ALERT:
                          if (task.getStatus() != ExecutionResult.FAILURE) {
                            task.setStatus(status);
                          }
case NOTHING_TO_DO:
                        if (task.getStatus() != ExecutionResult.SUCCESS_WITH_ALERT && task.getStatus() != ExecutionResult.SUCCESS_NO_ALERT && task.getStatus() != ExecutionResult.FAILURE) {
                          task.setStatus(status);
                        }
                      break;
case SKIPPED:
                    if (task.getStatus() != ExecutionResult.SUCCESS_WITH_ALERT && task.getStatus() != ExecutionResult.SUCCESS_NO_ALERT && task.getStatus() != ExecutionResult.FAILURE) {
                      task.setStatus(status);
                    }
                  break;
case FAILURE:
                task.setStatus(status);
default :
              task.setStatus(status);
            if (!isMigrationOnNewProject()) {
              if (!hadFailed) {
                hadFailed=true;
                Property prop=object.getProperty();
                Resource resource=prop.eResource();
                String itemInfo=null;
                if (resource != null) {
                  IPath path=URIHelper.convert(resource.getURI());
                  if (path != null) {
                    itemInfo=path.toPortableString();
                  }
                }
                if (itemInfo == null) {
                  itemInfo=prop.toString();
                }
                appendToLogFile(project,"String_Node_Str" + itemInfo + "String_Node_Str");
              }
              appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
            }
          break;
      }
    }
 catch (    Exception e) {
      doneThisSession.add(task);
      ExceptionHandler.process(e);
      if (!isMigrationOnNewProject()) {
        if (!hadFailed) {
          hadFailed=true;
          Property prop=object.getProperty();
          Resource resource=prop.eResource();
          String itemInfo=null;
          if (resource != null) {
            IPath path=URIHelper.convert(resource.getURI());
            if (path != null) {
              itemInfo=path.toPortableString();
            }
          }
          if (itemInfo == null) {
            itemInfo=prop.toString();
          }
          appendToLogFile(project,"String_Node_Str" + itemInfo + "String_Node_Str");
        }
        appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
      }
      log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
    }
  }
}
if (object instanceof RepositoryObject) {
  ((RepositoryObject)object).unload();
}
}
monitorWrap.subTask("String_Node_Str");
}
}
for (IProjectMigrationTask task : toExecute) {
MigrationTask mgTask=MigrationUtil.findMigrationTask(done,task);
if (mgTask == null && !task.isDeprecated()) {
try {
ExecutionResult status;
if (beforeLogon) {
  status=task.execute(project);
  task.setStatus(status);
}
 else {
  status=task.getStatus();
}
switch (status) {
case SUCCESS_WITH_ALERT:
  if (!isMigrationOnNewProject()) {
    doneThisSession.add(task);
  }
case SUCCESS_NO_ALERT:
if (!isMigrationOnNewProject()) {
  log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
  appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
}
case NOTHING_TO_DO:
if (!isMigrationOnNewProject() && task.getStatus() == ExecutionResult.NOTHING_TO_DO) {
appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
}
break;
case SKIPPED:
log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
if (!isMigrationOnNewProject()) {
appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
}
break;
case FAILURE:
doneThisSession.add(task);
default :
log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
break;
}
}
 catch (Exception e) {
doneThisSession.add(task);
ExceptionHandler.process(e);
log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
}
done.add(MigrationUtil.convertMigrationTask(task));
}
needSave=true;
}
}
 else {
for (IProjectMigrationTask task : toExecute) {
task.setStatus(ExecutionResult.NOTHING_TO_DO);
done.add(MigrationUtil.convertMigrationTask(task));
}
needSave=true;
}
if (needSave) {
saveProjectMigrationTasksDone(project,done);
}
if (!RelationshipItemBuilder.INDEX_VERSION.equals(project.getEmfProject().getItemsRelationVersion())) {
project.getEmfProject().setItemsRelationVersion(RelationshipItemBuilder.INDEX_VERSION);
}
if (!isMigrationOnNewProject()) {
RelationshipItemBuilder.getInstance().saveRelations();
}
}
 catch (PersistenceException e) {
throw new CoreException(new Status(Status.ERROR,"String_Node_Str",e.getMessage(),e));
}
if (!isMigrationOnNewProject() && !beforeLogon) {
appendToLogFile(project,"String_Node_Str");
}
}
}
;
try {
IWorkspace workspace1=ResourcesPlugin.getWorkspace();
ISchedulingRule schedulingRule=workspace1.getRoot();
workspace1.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitorWrap);
}
 catch (CoreException e) {
throw new PersistenceException(e);
}
}
}
;
repositoryWorkUnit.setAvoidUnloadResources(true);
repFactory.executeRepositoryWorkUnit(repositoryWorkUnit);
if (!beforeLogon) {
setMigrationOnNewProject(false);
}
}

Fixed version (ground truth):
@Override public void executeMigrationTasksForLogon(final Project project,final boolean beforeLogon,final IProgressMonitor monitorWrap){
  String taskDesc="String_Node_Str" + project.getLabel() + "String_Node_Str";
  log.trace(taskDesc);
  final List<IProjectMigrationTask> toExecute=GetTasksHelper.getProjectTasks(beforeLogon);
  final List<MigrationTask> done=new ArrayList<MigrationTask>(project.getEmfProject().getMigrationTask());
  if (beforeLogon) {
    boolean isNewProject=project.getEmfProject().getProductVersion() == null ? true : false;
    setMigrationOnNewProject(beforeLogon && isNewProject && done.isEmpty());
  }
  sortMigrationTasks(toExecute);
  int nbMigrationsToDo=0;
  for (  IProjectMigrationTask task : toExecute) {
    MigrationTask mgTask=MigrationUtil.findMigrationTask(done,task);
    if (mgTask == null && !task.isDeprecated()) {
      nbMigrationsToDo++;
    }
  }
  if (!beforeLogon && (!RelationshipItemBuilder.INDEX_VERSION.equals(project.getEmfProject().getItemsRelationVersion()) || nbMigrationsToDo > 0)) {
    MigrationUtil.removeMigrationTaskById(done,RELATION_TASK);
    RelationshipItemBuilder.getInstance().unloadRelations();
    RelationshipItemBuilder.getInstance().cleanTypeRelations(RelationshipItemBuilder.JOB_RELATION,RelationshipItemBuilder.JOB_RELATION,false);
    RelationshipItemBuilder.getInstance().cleanTypeRelations(RelationshipItemBuilder.JOBLET_RELATION,RelationshipItemBuilder.JOBLET_RELATION,true);
    RelationshipItemBuilder.getInstance().unloadRelations();
    nbMigrationsToDo++;
  }
  if (nbMigrationsToDo == 0) {
    return;
  }
  MigrationUtil.removeMigrationTaskById(done,"String_Node_Str");
  boolean haveAnyBinFolder=false;
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  IProject fsProject=workspace.getRoot().getProject(project.getTechnicalLabel());
  for (  ERepositoryObjectType type : (ERepositoryObjectType[])ERepositoryObjectType.values()) {
    if (!type.hasFolder()) {
      continue;
    }
    String folderName=ERepositoryObjectType.getFolderName(type);
    if (folderName == null || "String_Node_Str".equals(folderName)) {
      continue;
    }
    IFolder folder=fsProject.getFolder(folderName);
    if (folder.exists() && folder.getFolder("String_Node_Str").exists()) {
      haveAnyBinFolder=true;
      break;
    }
  }
  if (haveAnyBinFolder) {
    MigrationUtil.removeMigrationTaskById(done,"String_Node_Str");
  }
  final SubProgressMonitor subProgressMonitor=new SubProgressMonitor(monitorWrap,toExecute.size());
  IRepositoryService service=(IRepositoryService)GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
  final IProxyRepositoryFactory repFactory=service.getProxyRepositoryFactory();
  RepositoryWorkUnit repositoryWorkUnit=new RepositoryWorkUnit(project,taskDesc){
    @Override public void run() throws PersistenceException {
      final IWorkspaceRunnable op=new IWorkspaceRunnable(){
        @Override public void run(        IProgressMonitor monitor) throws CoreException {
          if (!isMigrationOnNewProject() && beforeLogon) {
            appendToLogFile(project,"String_Node_Str" + project.getLabel() + "String_Node_Str");
          }
          try {
            boolean needSave=false;
            if (!isMigrationOnNewProject()) {
              if (!beforeLogon) {
                ERepositoryObjectType[] types=(ERepositoryObjectType[])ERepositoryObjectType.values();
                Arrays.sort(types,new Comparator<ERepositoryObjectType>(){
                  @Override public int compare(                  ERepositoryObjectType arg0,                  ERepositoryObjectType arg1){
                    if (arg0 == ERepositoryObjectType.PROCESS) {
                      return 1;
                    }
                    if (arg0 == ERepositoryObjectType.JOBLET) {
                      return 1;
                    }
                    return 0;
                  }
                }
);
                for (                ERepositoryObjectType type : types) {
                  if (!type.isResourceItem()) {
                    continue;
                  }
                  List<IRepositoryViewObject> objects=repFactory.getAll(project,type,true,true);
                  for (                  IRepositoryViewObject object : objects) {
                    Item item=object.getProperty().getItem();
                    monitorWrap.subTask("String_Node_Str" + item.getProperty().getLabel());
                    boolean hadFailed=false;
                    subProgressMonitor.worked(1);
                    for (                    IProjectMigrationTask task : toExecute) {
                      if (monitorWrap.isCanceled()) {
                        throw new OperationCanceledException(Messages.getString("String_Node_Str",task.getName()));
                      }
                      MigrationTask mgTask=MigrationUtil.findMigrationTask(done,task);
                      if (mgTask == null && !task.isDeprecated()) {
                        try {
                          ExecutionResult status=task.execute(project,item);
switch (status) {
case SUCCESS_WITH_ALERT:
                            if (task.getStatus() != ExecutionResult.FAILURE) {
                              task.setStatus(status);
                            }
case SUCCESS_NO_ALERT:
                          if (task.getStatus() != ExecutionResult.FAILURE) {
                            task.setStatus(status);
                          }
case NOTHING_TO_DO:
                        if (task.getStatus() != ExecutionResult.SUCCESS_WITH_ALERT && task.getStatus() != ExecutionResult.SUCCESS_NO_ALERT && task.getStatus() != ExecutionResult.FAILURE) {
                          task.setStatus(status);
                        }
                      break;
case SKIPPED:
                    if (task.getStatus() != ExecutionResult.SUCCESS_WITH_ALERT && task.getStatus() != ExecutionResult.SUCCESS_NO_ALERT && task.getStatus() != ExecutionResult.FAILURE) {
                      task.setStatus(status);
                    }
                  break;
case FAILURE:
                task.setStatus(status);
default :
              task.setStatus(status);
            if (!isMigrationOnNewProject()) {
              if (!hadFailed) {
                hadFailed=true;
                Property prop=object.getProperty();
                Resource resource=prop.eResource();
                String itemInfo=null;
                if (resource != null) {
                  IPath path=URIHelper.convert(resource.getURI());
                  if (path != null) {
                    itemInfo=path.toPortableString();
                  }
                }
                if (itemInfo == null) {
                  itemInfo=prop.toString();
                }
                appendToLogFile(project,"String_Node_Str" + itemInfo + "String_Node_Str");
              }
              appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
            }
          break;
      }
    }
 catch (    Exception e) {
      doneThisSession.add(task);
      ExceptionHandler.process(e);
      if (!isMigrationOnNewProject()) {
        if (!hadFailed) {
          hadFailed=true;
          Property prop=object.getProperty();
          Resource resource=prop.eResource();
          String itemInfo=null;
          if (resource != null) {
            IPath path=URIHelper.convert(resource.getURI());
            if (path != null) {
              itemInfo=path.toPortableString();
            }
          }
          if (itemInfo == null) {
            itemInfo=prop.toString();
          }
          appendToLogFile(project,"String_Node_Str" + itemInfo + "String_Node_Str");
        }
        appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
      }
      log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
    }
  }
}
if (object instanceof RepositoryObject) {
  ((RepositoryObject)object).unload();
}
}
monitorWrap.subTask("String_Node_Str");
}
}
for (IProjectMigrationTask task : toExecute) {
MigrationTask mgTask=MigrationUtil.findMigrationTask(done,task);
if (mgTask == null && !task.isDeprecated()) {
try {
ExecutionResult status;
if (beforeLogon) {
  status=task.execute(project);
  task.setStatus(status);
}
 else {
  status=task.getStatus();
}
switch (status) {
case SUCCESS_WITH_ALERT:
  if (!isMigrationOnNewProject()) {
    doneThisSession.add(task);
  }
case SUCCESS_NO_ALERT:
if (!isMigrationOnNewProject()) {
  log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
  appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
}
case NOTHING_TO_DO:
if (!isMigrationOnNewProject() && task.getStatus() == ExecutionResult.NOTHING_TO_DO) {
appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
}
break;
case SKIPPED:
log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
if (!isMigrationOnNewProject()) {
appendToLogFile(project,"String_Node_Str" + task.getName() + "String_Node_Str");
}
break;
case FAILURE:
doneThisSession.add(task);
default :
log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
break;
}
}
 catch (Exception e) {
doneThisSession.add(task);
ExceptionHandler.process(e);
log.debug("String_Node_Str" + task.getName() + "String_Node_Str");
}
done.add(MigrationUtil.convertMigrationTask(task));
}
needSave=true;
}
}
 else {
for (IProjectMigrationTask task : toExecute) {
task.setStatus(ExecutionResult.NOTHING_TO_DO);
done.add(MigrationUtil.convertMigrationTask(task));
}
needSave=true;
}
if (needSave) {
saveProjectMigrationTasksDone(project,done);
}
if (!RelationshipItemBuilder.INDEX_VERSION.equals(project.getEmfProject().getItemsRelationVersion())) {
project.getEmfProject().setItemsRelationVersion(RelationshipItemBuilder.INDEX_VERSION);
}
if (!isMigrationOnNewProject()) {
RelationshipItemBuilder.getInstance().saveRelations();
}
}
 catch (PersistenceException e) {
throw new CoreException(new Status(Status.ERROR,"String_Node_Str",e.getMessage(),e));
}
if (!isMigrationOnNewProject() && !beforeLogon) {
appendToLogFile(project,"String_Node_Str");
}
}
}
;
try {
IWorkspace workspace1=ResourcesPlugin.getWorkspace();
ISchedulingRule schedulingRule=workspace1.getRoot();
workspace1.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitorWrap);
}
 catch (CoreException e) {
throw new PersistenceException(e);
}
}
}
;
repositoryWorkUnit.setAvoidUnloadResources(true);
repFactory.executeRepositoryWorkUnit(repositoryWorkUnit);
if (!beforeLogon) {
setMigrationOnNewProject(false);
}
}