Program: 118655
Project: 118655
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=null;
  if (element instanceof FakeElement) {
    if (connectionItem != null) {
      componentService=new ComponentServiceWithValueEvaluator(internalService.getComponentService(),new MetadataContextPropertyValueEvaluator(connectionItem.getConnection()));
      parameters=ComponentsUtils.getParametersFromForm(element,null,form,null,null);
      parameters.add(getUpdateParameter());
      currentParameters.clear();
    }
  }
 else {
    componentService=new ComponentServiceWithValueEvaluator(internalService.getComponentService(),new ComponentContextPropertyValueEvaluator((INode)element));
    parameters=ComponentsUtils.getParametersFromForm(element,section,((INode)element).getComponentProperties(),null,form,null,null);
  }
  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(parameter.getFieldType())) {
        if (parameter.getChildParameters().size() == 0) {
          IElementParameter schemaParameter=element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE,section);
          parameter.getChildParameters().putAll(schemaParameter.getChildParameters());
        }
      }
      if (isRepository(element)) {
        String repositoryValue=parameter.getRepositoryValue();
        if (repositoryValue == null) {
          if (parameter.getValue() != null) {
            parameter.setRepositoryValue(parameter.getName());
            repositoryValue=parameter.getRepositoryValue();
          }
        }
        if (parameter.isShow(currentParameters) && (repositoryValue != null) && (!parameter.getName().equals(EParameterName.PROPERTY_TYPE.getName()))&& parameter.getCategory() == section) {
          parameter.setRepositoryValueUsed(true);
          parameter.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=null;
  if (element instanceof FakeElement) {
    Connection theConnection=null;
    if (connectionItem != null) {
      theConnection=connectionItem.getConnection();
    }
    componentService=new ComponentServiceWithValueEvaluator(internalService.getComponentService(),new MetadataContextPropertyValueEvaluator(theConnection));
    parameters=ComponentsUtils.getParametersFromForm(element,form);
    parameters.add(getUpdateParameter());
    currentParameters.clear();
  }
 else {
    componentService=new ComponentServiceWithValueEvaluator(internalService.getComponentService(),new ComponentContextPropertyValueEvaluator((INode)element));
    parameters=ComponentsUtils.getParametersFromForm(element,section,((INode)element).getComponentProperties(),form);
  }
  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(parameter.getFieldType())) {
        if (parameter.getChildParameters().size() == 0) {
          IElementParameter schemaParameter=element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE,section);
          parameter.getChildParameters().putAll(schemaParameter.getChildParameters());
        }
      }
      if (isRepository(element)) {
        String repositoryValue=parameter.getRepositoryValue();
        if (repositoryValue == null) {
          if (parameter.getValue() != null) {
            parameter.setRepositoryValue(parameter.getName());
            repositoryValue=parameter.getRepositoryValue();
          }
        }
        if (parameter.isShow(currentParameters) && (repositoryValue != null) && (!parameter.getName().equals(EParameterName.PROPERTY_TYPE.getName()))&& parameter.getCategory() == section) {
          parameter.setRepositoryValueUsed(true);
          parameter.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;
}