Program: 125853
Project: 125853
Buggy source:
/** 
 * ggu Comment method "addInContextModelForProcessItem".
 */
public static boolean addInContextModelForProcessItem(Item item,Map<String,Set<String>> contextVars,List<ContextItem> allContextItems){
  ProcessType processType=null;
  if (item instanceof ProcessItem) {
    processType=((ProcessItem)item).getProcess();
  }
 else   if (item instanceof JobletProcessItem) {
    processType=((JobletProcessItem)item).getJobletProcess();
  }
  boolean added=false;
  if (processType != null) {
    if (allContextItems == null) {
      allContextItems=ContextUtils.getAllContextItem();
    }
    for (    String id : contextVars.keySet()) {
      ConnectionItem connItem=MetadataToolHelper.getConnectionItemByItemId(id,false);
      if (connItem != null) {
        String contextId=connItem.getConnection().getContextId();
        if (contextId != null) {
          Set<String> set=contextVars.get(id);
          if (set != null) {
            ContextItem contextItem=getContextItemById(allContextItems,contextId);
            ContextType contextType=getContextTypeByName(contextItem,contextItem.getDefaultContext(),true);
            JobContextManager processJobManager=new JobContextManager(processType.getContext(),processType.getDefaultContext());
            boolean modified=false;
            for (            String varName : set) {
              ContextParameterType contextParameterType=ContextUtils.getContextParameterTypeByName(contextType,varName);
              IContextParameter contextParameter=processJobManager.getDefaultContext().getContextParameter(varName);
              if (contextParameter == null) {
                addContextParameterType(processJobManager,contextItem,contextParameterType);
                modified=true;
              }
            }
            if (modified) {
              processType.getContext().clear();
              processJobManager.saveToEmf(processType.getContext());
              added=true;
            }
          }
        }
      }
    }
  }
  return added;
}

Fixed version (ground truth):
/** 
 * ggu Comment method "addInContextModelForProcessItem".
 */
public static boolean addInContextModelForProcessItem(Item item,Map<String,Set<String>> contextVars,List<ContextItem> allContextItems){
  ProcessType processType=null;
  if (item instanceof ProcessItem) {
    processType=((ProcessItem)item).getProcess();
  }
 else   if (item instanceof JobletProcessItem) {
    processType=((JobletProcessItem)item).getJobletProcess();
  }
  boolean added=false;
  if (processType != null) {
    if (allContextItems == null) {
      allContextItems=ContextUtils.getAllContextItem();
    }
    for (    String id : contextVars.keySet()) {
      ConnectionItem connItem=MetadataToolHelper.getConnectionItemByItemId(id,false);
      if (connItem != null) {
        String contextId=connItem.getConnection().getContextId();
        if (contextId != null) {
          Set<String> set=contextVars.get(id);
          if (set != null) {
            ContextItem contextItem=getContextItemById(allContextItems,contextId);
            ContextType contextType=getContextTypeByName(contextItem,contextItem.getDefaultContext(),true);
            JobContextManager processJobManager=new JobContextManager(processType.getContext(),processType.getDefaultContext());
            boolean modified=false;
            for (            String varName : set) {
              ContextParameterType contextParameterType=ContextUtils.getContextParameterTypeByName(contextType,varName);
              IContextParameter contextParameter=processJobManager.getDefaultContext().getContextParameter(varName);
              if (contextParameter == null) {
                addContextParameterType(processJobManager,contextItem,contextParameterType);
                modified=true;
              }
            }
            if (modified) {
              processJobManager.saveToEmf(processType.getContext());
              added=true;
            }
          }
        }
      }
    }
  }
  return added;
}