Program: 51172
Project: 51172
Buggy source:
/** 
 * Locates a member specified by its member name, from an array of members.  If an exact match isn't found, but a matchType of BEFORE or AFTER is specified, then the closest matching member is returned.
 * @param members array of members to search from
 * @param parent parent member corresponding to the member being searchedfor
 * @param level level of the member
 * @param searchName member name
 * @param matchType match type
 * @param caseInsensitive if true, use case insensitive search (ifapplicable) when when doing exact searches
 * @return matching member (if it exists) or the closest matching onein the case of a BEFORE or AFTER search
 */
public static Member findBestMemberMatch(List<? extends Member> members,RolapMember parent,RolapLevel level,Id.Segment searchName,MatchType matchType,boolean caseInsensitive){
  Member searchMember=level.getHierarchy().createMember(parent,level,searchName.name,null);
  Member bestMatch=null;
  for (  Member member : members) {
    int rc;
    if (searchName.quoting == Id.Quoting.KEY && member instanceof RolapMember) {
      if (((RolapMember)member).getKey().toString().equals(searchName.name)) {
        return member;
      }
    }
    if (matchType == MatchType.EXACT) {
      if (caseInsensitive) {
        rc=Util.compareName(member.getName(),searchName.name);
      }
 else {
        rc=member.getName().compareTo(searchName.name);
      }
    }
 else {
      rc=FunUtil.compareSiblingMembers(member,searchMember);
    }
    if (rc == 0) {
      return member;
    }
    if (matchType == MatchType.BEFORE) {
      if (rc < 0 && (bestMatch == null || FunUtil.compareSiblingMembers(member,bestMatch) > 0)) {
        bestMatch=member;
      }
    }
 else     if (matchType == MatchType.AFTER) {
      if (rc > 0 && (bestMatch == null || FunUtil.compareSiblingMembers(member,bestMatch) < 0)) {
        bestMatch=member;
      }
    }
  }
  if (matchType == MatchType.EXACT) {
    return null;
  }
  return bestMatch;
}

Fixed version (ground truth):
/** 
 * Locates a member specified by its member name, from an array of members.  If an exact match isn't found, but a matchType of BEFORE or AFTER is specified, then the closest matching member is returned.
 * @param members array of members to search from
 * @param parent parent member corresponding to the member being searchedfor
 * @param level level of the member
 * @param searchName member name
 * @param matchType match type
 * @param caseInsensitive if true, use case insensitive search (ifapplicable) when when doing exact searches
 * @return matching member (if it exists) or the closest matching onein the case of a BEFORE or AFTER search
 */
public static Member findBestMemberMatch(List<? extends Member> members,RolapMember parent,RolapLevel level,Id.Segment searchName,MatchType matchType,boolean caseInsensitive){
  Member searchMember=level.getHierarchy().createMember(parent,level,searchName.name,null);
  Member bestMatch=null;
  for (  Member member : members) {
    int rc;
    if (searchName.quoting == Id.Quoting.KEY && member instanceof RolapMember) {
      if (((RolapMember)member).getKey().toString().equals(searchName.name)) {
        return member;
      }
    }
    if (matchType.isExact()) {
      if (caseInsensitive) {
        rc=Util.compareName(member.getName(),searchName.name);
      }
 else {
        rc=member.getName().compareTo(searchName.name);
      }
    }
 else {
      rc=FunUtil.compareSiblingMembers(member,searchMember);
    }
    if (rc == 0) {
      return member;
    }
    if (matchType == MatchType.BEFORE) {
      if (rc < 0 && (bestMatch == null || FunUtil.compareSiblingMembers(member,bestMatch) > 0)) {
        bestMatch=member;
      }
    }
 else     if (matchType == MatchType.AFTER) {
      if (rc > 0 && (bestMatch == null || FunUtil.compareSiblingMembers(member,bestMatch) < 0)) {
        bestMatch=member;
      }
    }
  }
  if (matchType.isExact()) {
    return null;
  }
  return bestMatch;
}