Program: 125854
Project: 125854
Buggy source:
@Override public void saveToEmf(EList contextTypeList){
  ContextType contextType;
  IContext context;
  EList contextTypeParamList;
  ContextParameterType contextParamType;
  IContextParameter contextParam;
  if (listContext.isEmpty()) {
    retrieveDefaultContext();
  }
  for (int i=0; i < listContext.size(); i++) {
    contextType=TalendFileFactory.eINSTANCE.createContextType();
    context=listContext.get(i);
    contextType.setName(context.getName());
    contextType.setConfirmationNeeded(context.isConfirmationNeeded());
    contextTypeParamList=contextType.getContextParameter();
    if (context.getContextParameterList() != null) {
      for (int j=0; j < context.getContextParameterList().size(); j++) {
        contextParamType=TalendFileFactory.eINSTANCE.createContextParameterType();
        contextParam=context.getContextParameterList().get(j);
        contextParamType.setName(contextParam.getName());
        contextParamType.setPrompt(contextParam.getPrompt());
        contextParamType.setType(contextParam.getType());
        contextParamType.setRawValue(contextParam.getValue());
        contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
        contextParamType.setComment(contextParam.getComment());
        if (!contextParam.isBuiltIn()) {
          Item item=ContextUtils.getRepositoryContextItemById(contextParam.getSource());
          if (item != null) {
            contextParamType.setRepositoryContextId(item.getProperty().getId());
          }
        }
        contextTypeParamList.add(contextParamType);
      }
    }
    contextTypeList.add(contextType);
  }
}

Fixed version (ground truth):
/** 
 * If the context group or context parameter have existed, just update the attributes. If not existed, will create new one. If not existed any more, will be removed.
 */
@Override public void saveToEmf(EList contextTypeList){
  if (contextTypeList == null) {
    return;
  }
  if (listContext.isEmpty()) {
    retrieveDefaultContext();
  }
  EList newcontextTypeList=new BasicEList();
  for (int i=0; i < listContext.size(); i++) {
    IContext context=listContext.get(i);
    String contextGroupName=context.getName();
    ContextType contextType=findContextType(contextTypeList,contextGroupName);
    if (contextType == null) {
      contextType=TalendFileFactory.eINSTANCE.createContextType();
      contextType.setName(contextGroupName);
    }
    contextType.setConfirmationNeeded(context.isConfirmationNeeded());
    newcontextTypeList.add(contextType);
    EList contextTypeParamList=contextType.getContextParameter();
    List<IContextParameter> contextParameterList=context.getContextParameterList();
    EList newContextTypeParamList=new BasicEList();
    if (contextParameterList != null) {
      for (int j=0; j < contextParameterList.size(); j++) {
        IContextParameter contextParam=contextParameterList.get(j);
        ContextParameterType contextParamType=findContextParameterType(contextTypeParamList,contextParam.getName());
        if (contextParamType == null) {
          contextParamType=TalendFileFactory.eINSTANCE.createContextParameterType();
          contextParamType.setName(contextParam.getName());
        }
        newContextTypeParamList.add(contextParamType);
        contextParamType.setPrompt(contextParam.getPrompt());
        contextParamType.setType(contextParam.getType());
        contextParamType.setRawValue(contextParam.getValue());
        contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
        contextParamType.setComment(contextParam.getComment());
        if (!contextParam.isBuiltIn()) {
          Item item=ContextUtils.getRepositoryContextItemById(contextParam.getSource());
          if (item != null) {
            contextParamType.setRepositoryContextId(item.getProperty().getId());
          }
        }
      }
      contextTypeParamList.clear();
      contextTypeParamList.addAll(newContextTypeParamList);
    }
  }
  contextTypeList.clear();
  contextTypeList.addAll(newcontextTypeList);
}