Program: 70046
Project: 70046
Buggy source:
private List getSelectMemberValueList(){
  TabularCubeHandle tabularCube=getCubeHandle();
  List valueList=new ArrayList();
  List extValueList=getExistValueList();
  for (int i=0; i < extValueList.size(); i++) {
    MemberValueHandle tmpMemberValue=(MemberValueHandle)extValueList.get(i);
    String value=tmpMemberValue.getValue();
    if (value == null || value.length() == 0) {
      return new ArrayList();
    }
    valueList.add(value);
  }
  Object[] values=valueList.toArray(new Object[valueList.size()]);
  if (values.length == 0) {
    values=null;
  }
  DimensionLevel levelDens[]=null;
  if (values != null) {
    levelDens=new DimensionLevel[values.length];
    for (int i=0; i < values.length; i++) {
      Object obj=referencedLevelList.get(i);
      if (obj == null || (!(obj instanceof DimensionLevel))) {
        return new ArrayList();
      }
      levelDens[i]=(DimensionLevel)obj;
    }
  }
 else {
    levelDens=null;
  }
  String targetLevel=null;
  int index=0;
  if (values != null && values.length > 0 && values.length + 1 <= referencedLevelList.size()) {
    index=values.length;
  }
  DimensionLevel levelDefn=(DimensionLevel)referencedLevelList.get(index);
  String levelName=levelDefn.getLevelName();
  String dimensionName=levelDefn.getDimensionName();
  targetLevel=ExpressionUtil.createJSDimensionExpression(dimensionName,levelName);
  if (tabularCube == null || (targetLevel == null || targetLevel.length() == 0)) {
    return new ArrayList();
  }
  Iterator iter=null;
  DataRequestSession session=null;
  try {
    session=DataRequestSession.newSession(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION));
    iter=session.getCubeQueryUtil().getMemberValueIterator(tabularCube,targetLevel,levelDens,values);
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,e.getMessage(),e);
  }
 finally {
    if (session != null) {
      session.shutdown();
    }
  }
  List retList=new ArrayList();
  int count=0;
  int MAX_COUNT=PreferenceFactory.getInstance().getPreferences(CrosstabPlugin.getDefault(),UIUtil.getCurrentProject()).getInt(CrosstabPlugin.PREFERENCE_FILTER_LIMIT);
  while (iter != null && iter.hasNext()) {
    Object obj=iter.next();
    if (obj != null) {
      if (retList.indexOf(obj) < 0) {
        retList.add(obj);
        if (++count >= MAX_COUNT) {
          break;
        }
      }
    }
  }
  return retList;
}

Fixed version (ground truth):
private List getSelectMemberValueList(){
  TabularCubeHandle tabularCube=getCubeHandle();
  List valueList=new ArrayList();
  List extValueList=getExistValueList();
  for (int i=0; i < extValueList.size(); i++) {
    MemberValueHandle tmpMemberValue=(MemberValueHandle)extValueList.get(i);
    String value=tmpMemberValue.getValue();
    if (value == null || value.length() == 0) {
      return new ArrayList();
    }
    valueList.add(value);
  }
  Object[] values=valueList.toArray(new Object[valueList.size()]);
  if (values.length == 0) {
    values=null;
  }
  DimensionLevel levelDens[]=null;
  if (values != null) {
    levelDens=new DimensionLevel[values.length];
    for (int i=0; i < values.length; i++) {
      Object obj=referencedLevelList.get(i);
      if (obj == null || (!(obj instanceof DimensionLevel))) {
        return new ArrayList();
      }
      levelDens[i]=(DimensionLevel)obj;
    }
  }
 else {
    levelDens=null;
  }
  String targetLevel=null;
  int index=0;
  if (values != null && values.length > 0 && values.length + 1 <= referencedLevelList.size()) {
    index=values.length;
  }
  DimensionLevel levelDefn=(DimensionLevel)referencedLevelList.get(index);
  String levelName=levelDefn.getLevelName();
  String dimensionName=levelDefn.getDimensionName();
  targetLevel=ExpressionUtil.createJSDimensionExpression(dimensionName,levelName);
  if (tabularCube == null || (targetLevel == null || targetLevel.length() == 0)) {
    return new ArrayList();
  }
  Iterator iter=null;
  DataRequestSession session=null;
  try {
    session=DataRequestSession.newSession(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION));
    iter=session.getCubeQueryUtil().getMemberValueIterator(tabularCube,targetLevel,levelDens,values);
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,e.getMessage(),e);
  }
  List retList=new ArrayList();
  int count=0;
  int MAX_COUNT=PreferenceFactory.getInstance().getPreferences(CrosstabPlugin.getDefault(),UIUtil.getCurrentProject()).getInt(CrosstabPlugin.PREFERENCE_FILTER_LIMIT);
  while (iter != null && iter.hasNext()) {
    Object obj=iter.next();
    if (obj != null) {
      if (retList.indexOf(obj) < 0) {
        retList.add(obj);
        if (++count >= MAX_COUNT) {
          break;
        }
      }
    }
  }
  if (session != null) {
    session.shutdown();
  }
  return retList;
}