Program: 126409
Project: 126409
Buggy source:
@Override public void loadFromEmf(EList contextTypeList,String defaultContextName){
  IContext context;
  ContextType contextType;
  List<IContextParameter> contextParamList;
  EList contextTypeParamList;
  ContextParameterType contextParamType;
  JobContextParameter contextParam;
  lostParameters.clear();
  listContext.clear();
  if (contextTypeList == null || contextTypeList.isEmpty()) {
    retrieveDefaultContext();
    return;
  }
  List<ContextItem> contextItemList=ContextUtils.getAllContextItem();
  boolean setDefault=false;
  for (int i=0; i < contextTypeList.size(); i++) {
    contextType=(ContextType)contextTypeList.get(i);
    String name=contextType.getName();
    if (name == null) {
      name=IContext.DEFAULT;
    }
    context=new JobContext(name);
    context.setConfirmationNeeded(contextType.isConfirmationNeeded());
    contextParamList=new ArrayList<IContextParameter>();
    contextTypeParamList=contextType.getContextParameter();
    Set<String> paramNamesInCurrentContext=new HashSet<String>();
    for (int j=0; j < contextTypeParamList.size(); j++) {
      contextParamType=(ContextParameterType)contextTypeParamList.get(j);
      if (paramNamesInCurrentContext.contains(contextParamType.getName())) {
        continue;
      }
      paramNamesInCurrentContext.add(contextParamType.getName());
      contextParam=new JobContextParameter();
      contextParam.setContext(context);
      contextParam.setName(contextParamType.getName());
      contextParam.setPrompt(contextParamType.getPrompt());
      originalParamerters.add(contextParam.getName());
      boolean exists=false;
      ECodeLanguage curLanguage=LanguageManager.getCurrentLanguage();
      if (curLanguage == ECodeLanguage.JAVA) {
        exists=true;
        try {
          ContextParameterJavaTypeManager.getJavaTypeFromId(contextParamType.getType());
        }
 catch (        IllegalArgumentException e) {
          exists=false;
        }
      }
 else {
        String[] existingTypes;
        existingTypes=ContextParameterJavaTypeManager.getPerlTypesLabels();
        for (        String existingType : existingTypes) {
          if (existingType.equals(contextParamType.getType())) {
            exists=true;
          }
        }
      }
      if (exists) {
        contextParam.setType(contextParamType.getType());
      }
 else {
        contextParam.setType(MetadataTalendType.getDefaultTalendType());
      }
      contextParam.setValue(contextParamType.getValue());
      contextParam.setPromptNeeded(contextParamType.isPromptNeeded());
      contextParam.setComment(contextParamType.getComment());
      String repositoryContextId=contextParamType.getRepositoryContextId();
      String source=IContextParameter.BUILT_IN;
      if (repositoryContextId != null && !"String_Node_Str".equals(repositoryContextId)) {
        ContextItem item=ContextUtils.getContextItemById(contextItemList,repositoryContextId);
        if (item != null) {
          source=item.getProperty().getId();
        }
 else {
          lostParameters.add(contextParam.getName());
        }
      }
      contextParam.setSource(source);
      contextParamList.add(contextParam);
    }
    context.setContextParameterList(contextParamList);
    if (context.getName().equals(defaultContextName)) {
      setDefaultContext(context);
      setDefault=true;
    }
    listContext.add(context);
  }
  if (!setDefault) {
    setDefaultContext(listContext.get(0));
  }
}

Fixed version (ground truth):
@Override public void loadFromEmf(EList contextTypeList,String defaultContextName){
  IContext context;
  ContextType contextType;
  List<IContextParameter> contextParamList;
  EList contextTypeParamList;
  ContextParameterType contextParamType;
  JobContextParameter contextParam;
  lostParameters.clear();
  listContext.clear();
  if (contextTypeList == null || contextTypeList.isEmpty()) {
    retrieveDefaultContext();
    return;
  }
  List<ContextItem> contextItemList=ContextUtils.getAllContextItem();
  boolean setDefault=false;
  for (int i=0; i < contextTypeList.size(); i++) {
    contextType=(ContextType)contextTypeList.get(i);
    String name=contextType.getName();
    if (name == null) {
      name=IContext.DEFAULT;
    }
    context=new JobContext(name);
    context.setConfirmationNeeded(contextType.isConfirmationNeeded());
    contextParamList=new ArrayList<IContextParameter>();
    contextTypeParamList=contextType.getContextParameter();
    Set<String> paramNamesInCurrentContext=new HashSet<String>();
    for (int j=0; j < contextTypeParamList.size(); j++) {
      contextParamType=(ContextParameterType)contextTypeParamList.get(j);
      if (paramNamesInCurrentContext.contains(contextParamType.getName())) {
        continue;
      }
      paramNamesInCurrentContext.add(contextParamType.getName());
      contextParam=new JobContextParameter();
      contextParam.setContext(context);
      contextParam.setName(contextParamType.getName());
      contextParam.setPrompt(contextParamType.getPrompt());
      originalParamerters.add(contextParam.getName());
      boolean exists=false;
      ECodeLanguage curLanguage=LanguageManager.getCurrentLanguage();
      if (curLanguage == ECodeLanguage.JAVA) {
        exists=true;
        try {
          ContextParameterJavaTypeManager.getJavaTypeFromId(contextParamType.getType());
        }
 catch (        IllegalArgumentException e) {
          exists=false;
        }
      }
 else {
        String[] existingTypes;
        existingTypes=ContextParameterJavaTypeManager.getPerlTypesLabels();
        for (        String existingType : existingTypes) {
          if (existingType.equals(contextParamType.getType())) {
            exists=true;
          }
        }
      }
      if (exists) {
        contextParam.setType(contextParamType.getType());
      }
 else {
        contextParam.setType(MetadataTalendType.getDefaultTalendType());
      }
      contextParam.setValue(contextParamType.getValue());
      contextParam.setPromptNeeded(contextParamType.isPromptNeeded());
      contextParam.setComment(contextParamType.getComment());
      String repositoryContextId=contextParamType.getRepositoryContextId();
      String source=IContextParameter.BUILT_IN;
      if (repositoryContextId != null && !"String_Node_Str".equals(repositoryContextId)) {
        Item item=ContextUtils.getContextItemById(contextItemList,repositoryContextId);
        if (item == null) {
          item=ContextUtils.getContextItemById3(repositoryContextId);
        }
        if (item != null) {
          source=item.getProperty().getId();
        }
 else {
          lostParameters.add(contextParam.getName());
        }
      }
      contextParam.setSource(source);
      contextParamList.add(contextParam);
    }
    context.setContextParameterList(contextParamList);
    if (context.getName().equals(defaultContextName)) {
      setDefaultContext(context);
      setDefault=true;
    }
    listContext.add(context);
  }
  if (!setDefault) {
    setDefaultContext(listContext.get(0));
  }
}