Program: 76248
Project: 76248
Buggy source:
/** 
 * Find the value matcher in cube cursor. Based on sort direction and compared result, decide to move on/back along resultset.
 * @param rs
 * @param levelList
 * @param valueMap
 * @param aggrIndex
 * @return
 */
private boolean findValueMatcher(IAggregationResultSet rs,List levelList,Map valueMap,int aggrIndex){
  if (levelList.isEmpty())   return true;
  int start=0, state=0;
  boolean find=false;
  for (; start < levelList.size(); ) {
    String levelName=levelList.get(start).toString();
    Object value1=valueMap.get(levelName);
    Object value2=rs.getLevelKeyValue(rs.getLevelIndex(levelName))[0];
    int sortType=rs.getSortType(rs.getLevelIndex(levelName)) == IDimensionSortDefn.SORT_DESC ? -1 : 1;
    int direction=sortType * ((Comparable)value1).compareTo(value2) < 0 ? -1 : ((Comparable)value1).compareTo(value2) == 0 ? 0 : 1;
    if (direction < 0 && currentPosition[aggrIndex] > 0 && (state == 0 || state == direction)) {
      state=direction;
      try {
        rs.seek(--currentPosition[aggrIndex]);
      }
 catch (      IOException e) {
        find=false;
      }
      start=0;
      continue;
    }
 else     if (direction > 0 && currentPosition[aggrIndex] < rs.length() && (state == 0 || state == direction)) {
      state=direction;
      try {
        rs.seek(++currentPosition[aggrIndex]);
      }
 catch (      IOException e) {
        find=false;
      }
      start=0;
      continue;
    }
 else     if (direction == 0) {
      if (start == levelList.size() - 1) {
        find=true;
        break;
      }
 else {
        start++;
        continue;
      }
    }
 else     if (currentPosition[aggrIndex] < 0 || currentPosition[aggrIndex] >= rs.length()) {
      return false;
    }
 else     return false;
  }
  return find;
}

Fixed version (ground truth):
/** 
 * Find the value matcher in cube cursor. Based on sort direction and compared result, decide to move on/back along resultset.
 * @param rs
 * @param levelList
 * @param valueMap
 * @param aggrIndex
 * @return
 */
private boolean findValueMatcher(IAggregationResultSet rs,List levelList,Map valueMap,int aggrIndex){
  if (levelList.isEmpty())   return true;
  int start=0, state=0;
  boolean find=false;
  for (; start < levelList.size(); ) {
    String levelName=levelList.get(start).toString();
    Object value1=valueMap.get(levelName);
    Object value2=rs.getLevelKeyValue(rs.getLevelIndex(levelName))[0];
    int sortType=rs.getSortType(rs.getLevelIndex(levelName)) == IDimensionSortDefn.SORT_DESC ? -1 : 1;
    int direction=sortType * ((Comparable)value1).compareTo(value2) < 0 ? -1 : ((Comparable)value1).compareTo(value2) == 0 ? 0 : 1;
    if (direction < 0 && currentPosition[aggrIndex] > 0 && (state == 0 || state == direction)) {
      state=direction;
      try {
        rs.seek(--currentPosition[aggrIndex]);
      }
 catch (      IOException e) {
        find=false;
      }
      start=0;
      continue;
    }
 else     if (direction > 0 && currentPosition[aggrIndex] < rs.length() - 1 && (state == 0 || state == direction)) {
      state=direction;
      try {
        rs.seek(++currentPosition[aggrIndex]);
      }
 catch (      IOException e) {
        find=false;
      }
      start=0;
      continue;
    }
 else     if (direction == 0) {
      if (start == levelList.size() - 1) {
        find=true;
        break;
      }
 else {
        start++;
        continue;
      }
    }
 else     if (currentPosition[aggrIndex] < 0 || currentPosition[aggrIndex] >= rs.length()) {
      return false;
    }
 else     return false;
  }
  return find;
}