Program: 51466
Project: 51466
Buggy source:
private int internalAddRow(ResultSet resultSet,int column) throws SQLException {
  RolapMember member=null;
  for (int i=0; i <= levelDepth; i++) {
    RolapLevel childLevel=levels[i];
    if (childLevel.isAll()) {
      member=allMember;
      continue;
    }
    Object value=resultSet.getObject(++column);
    if (value == null) {
      value=RolapUtil.sqlNullValue;
    }
    Object captionValue;
    if (childLevel.hasCaptionColumn()) {
      captionValue=resultSet.getObject(++column);
    }
 else {
      captionValue=null;
    }
    RolapMember parentMember=member;
    Object key=cache.makeKey(parentMember,value);
    member=cache.getMember(key);
    if (member == null) {
      member=memberBuilder.makeMember(parentMember,childLevel,value,captionValue,parentChild,resultSet,key,column);
    }
    column+=childLevel.getProperties().length;
    if (member != members[i]) {
      List children=siblings[i + 1];
      if (children != null) {
        MemberChildrenConstraint mcc=constraint.getMemberChildrenConstraint(members[i]);
        if (mcc != null)         cache.putChildren(members[i],mcc,children);
      }
      MemberChildrenConstraint mcc=constraint.getMemberChildrenConstraint(member);
      List cachedChildren=cache.getChildrenFromCache(member,mcc);
      if (i < levelDepth && cachedChildren == null) {
        siblings[i + 1]=new ArrayList();
      }
 else {
        siblings[i + 1]=null;
      }
      members[i]=member;
      if (siblings[i] != null) {
        if (value == RolapUtil.sqlNullValue) {
          addAsOldestSibling(siblings[i],member);
        }
 else {
          siblings[i].add(member);
        }
      }
    }
  }
  list.add(member);
  return column;
}

Fixed version (ground truth):
private int internalAddRow(ResultSet resultSet,int column) throws SQLException {
  RolapMember member=null;
  if (currMember != null) {
    member=currMember;
  }
 else {
    for (int i=0; i <= levelDepth; i++) {
      RolapLevel childLevel=levels[i];
      if (childLevel.isAll()) {
        member=allMember;
        continue;
      }
      Object value=resultSet.getObject(++column);
      if (value == null) {
        value=RolapUtil.sqlNullValue;
      }
      Object captionValue;
      if (childLevel.hasCaptionColumn()) {
        captionValue=resultSet.getObject(++column);
      }
 else {
        captionValue=null;
      }
      RolapMember parentMember=member;
      Object key=cache.makeKey(parentMember,value);
      member=cache.getMember(key);
      if (member == null) {
        member=memberBuilder.makeMember(parentMember,childLevel,value,captionValue,parentChild,resultSet,key,column);
      }
      column+=childLevel.getProperties().length;
      if (member != members[i]) {
        List children=siblings[i + 1];
        if (children != null) {
          MemberChildrenConstraint mcc=constraint.getMemberChildrenConstraint(members[i]);
          if (mcc != null)           cache.putChildren(members[i],mcc,children);
        }
        MemberChildrenConstraint mcc=constraint.getMemberChildrenConstraint(member);
        List cachedChildren=cache.getChildrenFromCache(member,mcc);
        if (i < levelDepth && cachedChildren == null) {
          siblings[i + 1]=new ArrayList();
        }
 else {
          siblings[i + 1]=null;
        }
        members[i]=member;
        if (siblings[i] != null) {
          if (value == RolapUtil.sqlNullValue) {
            addAsOldestSibling(siblings[i],member);
          }
 else {
            siblings[i].add(member);
          }
        }
      }
    }
    currMember=member;
  }
  list.add(member);
  return column;
}