Program: 78162
Project: 78162
Buggy source:
private static Collection convertEngineParameters(Collection params,IGetParameterDefinitionTask task,boolean includeGroups){
  if (params == null)   return Collections.EMPTY_LIST;
  List ret=new ArrayList();
  List groups=new ArrayList();
  for (Iterator it=params.iterator(); it.hasNext(); ) {
    Object o=it.next();
    if (o instanceof IParameterGroupDefn) {
      if (!includeGroups) {
        IParameterGroupDefn groupDef=(IParameterGroupDefn)o;
        List contents=new ArrayList(convertEngineParameters(groupDef.getContents(),task,true));
        ret.addAll(contents);
      }
      groups.add(o);
    }
  }
  for (Iterator it=params.iterator(); it.hasNext(); ) {
    Object o=it.next();
    if (o instanceof IScalarParameterDefn) {
      IScalarParameterDefn engineParam=(IScalarParameterDefn)o;
      ParameterGroupDefinition group=null;
      for (Iterator groupIt=groups.iterator(); groupIt.hasNext(); ) {
        IParameterGroupDefn tempGroup=(IParameterGroupDefn)groupIt.next();
        boolean cascade=tempGroup instanceof ICascadingParameterGroup;
        if (tempGroup.getContents().contains(engineParam)) {
          List contents=new ArrayList(convertEngineParameters(tempGroup.getContents(),task,true));
          group=new ParameterGroupDefinition(tempGroup.getName(),tempGroup.getDisplayName(),contents,cascade);
          break;
        }
      }
      ParameterDefinition param=convertScalarParameter(engineParam,group,task);
      ret.add(param);
    }
 else     if (o instanceof IParameterGroupDefn && includeGroups) {
      IParameterGroupDefn engineParam=(IParameterGroupDefn)o;
      boolean cascade=engineParam instanceof ICascadingParameterGroup;
      ParameterGroupDefinition paramGroup=new ParameterGroupDefinition(engineParam.getName(),engineParam.getDisplayName(),null,cascade);
      List contents=convertParametersInGroup(engineParam.getContents(),paramGroup,task);
      paramGroup.setParameters(contents);
      ret.add(paramGroup);
    }
  }
  return ret;
}

Fixed version (ground truth):
private static Collection convertEngineParameters(Collection params,IGetParameterDefinitionTask task,boolean includeGroups){
  if (params == null)   return Collections.EMPTY_LIST;
  List ret=new ArrayList();
  List groups=new ArrayList();
  for (Iterator it=params.iterator(); it.hasNext(); ) {
    Object o=it.next();
    if (o instanceof IParameterGroupDefn) {
      if (!includeGroups) {
        IParameterGroupDefn groupDef=(IParameterGroupDefn)o;
        ParameterGroupDefinition groupParam=convertGroupParameter(groupDef,task);
        ret.addAll(groupParam.getParameters());
      }
      groups.add(o);
    }
  }
  for (Iterator it=params.iterator(); it.hasNext(); ) {
    Object o=it.next();
    if (o instanceof IScalarParameterDefn) {
      IScalarParameterDefn engineParam=(IScalarParameterDefn)o;
      ParameterGroupDefinition group=null;
      for (Iterator groupIt=groups.iterator(); groupIt.hasNext(); ) {
        IParameterGroupDefn tempGroup=(IParameterGroupDefn)groupIt.next();
        boolean cascade=tempGroup instanceof ICascadingParameterGroup;
        if (tempGroup.getContents().contains(engineParam)) {
          List contents=new ArrayList(convertEngineParameters(tempGroup.getContents(),task,true));
          group=new ParameterGroupDefinition(tempGroup.getName(),tempGroup.getDisplayName(),contents,cascade);
          break;
        }
      }
      ParameterDefinition param=convertScalarParameter(engineParam,group,task);
      ret.add(param);
    }
 else     if (o instanceof IParameterGroupDefn && includeGroups) {
      IParameterGroupDefn engineParam=(IParameterGroupDefn)o;
      ParameterGroupDefinition paramGroup=convertGroupParameter(engineParam,task);
      ret.add(paramGroup);
    }
  }
  return ret;
}