Program: 118453
Project: 118453
Buggy source:
public List<ElementParameter> resetParameters(){
  final List<ElementParameter> newParameters=new ArrayList<>();
  List<ElementParameter> currentParameters=(List<ElementParameter>)element.getElementParameters();
  List<ElementParameter> parameters=new ArrayList<>();
  ComponentService componentService=internalService.getComponentService();
  Connection theConnection=null;
  if (connectionItem != null) {
    theConnection=connectionItem.getConnection();
  }
  Properties properties=null;
  PropertyValueEvaluator evaluator=null;
  if (element instanceof FakeElement) {
    properties=form.getProperties();
    evaluator=new MetadataContextPropertyValueEvaluator(theConnection);
    currentParameters.clear();
  }
 else {
    properties=((INode)element).getComponentProperties();
    evaluator=new ComponentContextPropertyValueEvaluator((INode)element);
  }
  if (properties instanceof ComponentProperties) {
    properties.setValueEvaluator(evaluator);
    properties.refreshLayout(form);
    properties.setValueEvaluator(null);
    parameters=ComponentsUtils.getParametersFromForm(element,section,(ComponentProperties)properties,form);
    addUpdateParameterIfNotExist(parameters);
    properties.setValueEvaluator(evaluator);
  }
  for (  ElementParameter parameter : parameters) {
    if (parameter instanceof GenericElementParameter) {
      GenericElementParameter genericElementParameter=(GenericElementParameter)parameter;
      genericElementParameter.setComponentService(componentService);
      genericElementParameter.setDrivedByForm(drivedByForm);
      genericElementParameter.callBeforePresent();
      genericElementParameter.addPropertyChangeListener(this);
      if (EParameterFieldType.SCHEMA_REFERENCE.equals(genericElementParameter.getFieldType())) {
        if (genericElementParameter.getChildParameters().size() == 0) {
          IElementParameter schemaParameter=element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE,section);
          genericElementParameter.getChildParameters().putAll(schemaParameter.getChildParameters());
        }
      }
 else       if (EParameterFieldType.NAME_SELECTION_AREA.equals(genericElementParameter.getFieldType()) && theConnection != null) {
        List<MetadataTable> metadataTables=SchemaUtils.getMetadataTables(theConnection,SubContainer.class);
        List<String> tableLabels=new ArrayList<>();
        for (        MetadataTable metaTable : metadataTables) {
          tableLabels.add(metaTable.getLabel());
        }
        genericElementParameter.setValue(tableLabels);
      }
      if (properties != null && isRepository(element)) {
        String repositoryValue=parameter.getRepositoryValue();
        if (repositoryValue == null) {
          if (genericElementParameter.getValue() != null) {
            genericElementParameter.setRepositoryValue(genericElementParameter.getName());
            repositoryValue=genericElementParameter.getRepositoryValue();
          }
        }
        if (parameter.isShow(currentParameters) && (repositoryValue != null) && (!parameter.getName().equals(EParameterName.PROPERTY_TYPE.getName()))&& parameter.getCategory() == section) {
          org.talend.daikon.properties.Property property=properties.getValuedProperty(parameter.getName());
          if (property != null && property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
            genericElementParameter.setRepositoryValueUsed(true);
            genericElementParameter.setReadOnly(true);
          }
        }
      }
    }
  }
  boolean added=false;
  for (  ElementParameter currentParameter : currentParameters) {
    if (EParameterName.UPDATE_COMPONENTS.getName().equals(currentParameter.getName())) {
      currentParameter.setValue(true);
    }
    if (currentParameter.isSerialized() && currentParameter.getCategory().equals(section)) {
      if (!added) {
        newParameters.addAll(parameters);
        added=true;
      }
      continue;
    }
    newParameters.add(currentParameter);
  }
  if (element instanceof FakeElement) {
    newParameters.addAll(parameters);
  }
  element.setElementParameters(newParameters);
  return newParameters;
}

Fixed version (ground truth):
public List<ElementParameter> resetParameters(){
  final List<ElementParameter> newParameters=new ArrayList<>();
  List<ElementParameter> currentParameters=(List<ElementParameter>)element.getElementParameters();
  List<ElementParameter> parameters=new ArrayList<>();
  ComponentService componentService=internalService.getComponentService();
  Connection theConnection=null;
  if (connectionItem != null) {
    theConnection=connectionItem.getConnection();
  }
  Properties properties=null;
  PropertyValueEvaluator evaluator=null;
  if (element instanceof FakeElement) {
    properties=form.getProperties();
    evaluator=new MetadataContextPropertyValueEvaluator(theConnection);
    currentParameters.clear();
  }
 else {
    properties=((INode)element).getComponentProperties();
    evaluator=new ComponentContextPropertyValueEvaluator((INode)element);
  }
  if (properties instanceof ComponentProperties) {
    properties.setValueEvaluator(evaluator);
    properties.refreshLayout(form);
    properties.setValueEvaluator(null);
    parameters=ComponentsUtils.getParametersFromForm(element,section,(ComponentProperties)properties,form);
    addUpdateParameterIfNotExist(parameters);
    properties.setValueEvaluator(evaluator);
  }
  for (  ElementParameter parameter : parameters) {
    if (parameter instanceof GenericElementParameter) {
      GenericElementParameter genericElementParameter=(GenericElementParameter)parameter;
      genericElementParameter.setComponentService(componentService);
      genericElementParameter.setDrivedByForm(drivedByForm);
      genericElementParameter.callBeforePresent();
      genericElementParameter.addPropertyChangeListener(this);
      if (EParameterFieldType.SCHEMA_REFERENCE.equals(genericElementParameter.getFieldType())) {
        if (genericElementParameter.getChildParameters().size() == 0) {
          IElementParameter schemaParameter=element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE,section);
          genericElementParameter.getChildParameters().putAll(schemaParameter.getChildParameters());
        }
      }
 else       if (EParameterFieldType.NAME_SELECTION_AREA.equals(genericElementParameter.getFieldType()) && theConnection != null) {
        List<?> possibleValues=genericElementParameter.getPossibleValues();
        if (possibleValues != null && possibleValues.size() > 0) {
          List<NamedThing> values=new ArrayList<>();
          List<MetadataTable> metadataTables=SchemaUtils.getMetadataTables(theConnection,SubContainer.class);
          List<String> tableLabels=new ArrayList<>();
          for (          MetadataTable metaTable : metadataTables) {
            tableLabels.add(metaTable.getLabel());
          }
          for (          Object valObj : possibleValues) {
            if (valObj instanceof NamedThing) {
              NamedThing value=(NamedThing)valObj;
              if (tableLabels.contains(value.getName())) {
                values.add(value);
              }
            }
          }
          genericElementParameter.setValue(values);
        }
      }
      if (properties != null && isRepository(element)) {
        String repositoryValue=genericElementParameter.getRepositoryValue();
        if (repositoryValue == null) {
          if (genericElementParameter.getValue() != null) {
            genericElementParameter.setRepositoryValue(genericElementParameter.getName());
            repositoryValue=genericElementParameter.getRepositoryValue();
          }
        }
        if (genericElementParameter.isShow(currentParameters) && (repositoryValue != null) && (!genericElementParameter.getName().equals(EParameterName.PROPERTY_TYPE.getName()))&& genericElementParameter.getCategory() == section) {
          org.talend.daikon.properties.Property property=properties.getValuedProperty(genericElementParameter.getName());
          if (property != null && property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
            genericElementParameter.setRepositoryValueUsed(true);
            genericElementParameter.setReadOnly(true);
          }
        }
      }
    }
  }
  boolean added=false;
  for (  ElementParameter currentParameter : currentParameters) {
    if (EParameterName.UPDATE_COMPONENTS.getName().equals(currentParameter.getName())) {
      currentParameter.setValue(true);
    }
    if (currentParameter.isSerialized() && currentParameter.getCategory().equals(section)) {
      if (!added) {
        newParameters.addAll(parameters);
        added=true;
      }
      continue;
    }
    newParameters.add(currentParameter);
  }
  if (element instanceof FakeElement) {
    newParameters.addAll(parameters);
  }
  element.setElementParameters(newParameters);
  return newParameters;
}