Program: 122387
Project: 122387
Buggy source:
private void createContext(List<Object> sourceList){
  if (sourceList.size() == 0) {
    return;
  }
  boolean created=false;
  for (  Object source : sourceList) {
    if (source instanceof RepositoryNode) {
      RepositoryNode sourceNode=(RepositoryNode)source;
      Item item=sourceNode.getObject().getProperty().getItem();
      if (item instanceof ContextItem) {
        ContextItem contextItem=(ContextItem)item;
        EList context=contextItem.getContext();
        Set<String> contextSet=new HashSet<String>();
        Iterator iterator=context.iterator();
        while (iterator.hasNext()) {
          Object obj=iterator.next();
          if (obj instanceof ContextTypeImpl) {
            EList contextParameters=((ContextTypeImpl)obj).getContextParameter();
            Iterator contextParas=contextParameters.iterator();
            while (contextParas.hasNext()) {
              ContextParameterTypeImpl contextParameterType=(ContextParameterTypeImpl)contextParas.next();
              String name=contextParameterType.getName();
              contextSet.add(name);
            }
          }
        }
        IEditorInput editorInput=editor.getEditorInput();
        if (editorInput instanceof JobEditorInput) {
          JobEditorInput jobInput=(JobEditorInput)editorInput;
          IProcess2 process=jobInput.getLoadedProcess();
          IContextManager contextManager=process.getContextManager();
          List<IContext> listContext=contextManager.getListContext();
          if (!ConnectionContextHelper.containsVariable(contextManager)) {
            ConnectionContextHelper.addContextVarForJob(process,contextItem,contextManager);
            created=true;
          }
 else {
            Set<String> addedContext=ConnectionContextHelper.checkAndAddContextVariables(contextItem,contextSet,contextManager,false);
            if (addedContext != null && addedContext.size() > 0) {
              ConnectionContextHelper.addContextVarForJob(process,contextItem,contextSet);
              created=true;
            }
          }
        }
      }
    }
  }
  if (created) {
    RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
  }
}

Fixed version (ground truth):
private void createContext(List<Object> sourceList){
  if (sourceList.size() == 0) {
    return;
  }
  boolean created=false;
  for (  Object source : sourceList) {
    if (source instanceof RepositoryNode) {
      RepositoryNode sourceNode=(RepositoryNode)source;
      Item item=sourceNode.getObject().getProperty().getItem();
      if (item instanceof ContextItem) {
        ContextItem contextItem=(ContextItem)item;
        EList context=contextItem.getContext();
        Set<String> contextSet=new HashSet<String>();
        Iterator iterator=context.iterator();
        while (iterator.hasNext()) {
          Object obj=iterator.next();
          if (obj instanceof ContextTypeImpl) {
            EList contextParameters=((ContextTypeImpl)obj).getContextParameter();
            Iterator contextParas=contextParameters.iterator();
            while (contextParas.hasNext()) {
              ContextParameterTypeImpl contextParameterType=(ContextParameterTypeImpl)contextParas.next();
              String name=contextParameterType.getName();
              contextSet.add(name);
            }
          }
        }
        IEditorInput editorInput=editor.getEditorInput();
        if (editorInput instanceof JobEditorInput) {
          JobEditorInput jobInput=(JobEditorInput)editorInput;
          IProcess2 process=jobInput.getLoadedProcess();
          IContextManager contextManager=process.getContextManager();
          List<IContext> listContext=contextManager.getListContext();
          Set<String> addedVars=ConnectionContextHelper.checkAndAddContextVariables(contextItem,contextSet,process.getContextManager(),false);
          if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem,contextManager,contextSet)) {
            Map<String,Set<String>> addedVarsMap=new HashMap<String,Set<String>>();
            addedVarsMap.put(item.getProperty().getLabel(),contextSet);
            if (ConnectionContextHelper.showContextdialog(process,contextItem,process.getContextManager(),addedVarsMap,contextSet)) {
              created=true;
            }
          }
        }
      }
    }
  }
  if (created) {
    RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
  }
}