Program: 51465
Project: 51465
Buggy source:
public List readTuples(Connection jdbcConnection){
  String sql=makeLevelMembersSql(jdbcConnection);
  ResultSet resultSet=null;
  try {
    resultSet=RolapUtil.executeQuery(jdbcConnection,sql,maxRows,"String_Node_Str" + targets);
    for (Iterator it=targets.iterator(); it.hasNext(); ) {
      ((Target)it.next()).open();
    }
    int limit=MondrianProperties.instance().ResultLimit.get();
    int nFetch=0;
    int nEnumTargets=0;
    for (Iterator it=targets.iterator(); it.hasNext(); ) {
      Target t=(Target)it.next();
      if (t.srcMembers != null) {
        nEnumTargets++;
      }
    }
    int[] srcMemberIdxes=null;
    if (nEnumTargets > 0) {
      srcMemberIdxes=new int[nEnumTargets];
    }
    while (resultSet.next()) {
      if (limit > 0 && limit < ++nFetch) {
        throw MondrianResource.instance().MemberFetchLimitExceeded.ex(new Long(limit));
      }
      if (nEnumTargets == 0) {
        int column=0;
        for (Iterator it=targets.iterator(); it.hasNext(); ) {
          Target t=(Target)it.next();
          column=t.addRow(resultSet,column);
        }
      }
 else {
        int firstEnumTarget=0;
        for (; firstEnumTarget < targets.size(); firstEnumTarget++) {
          if (((Target)targets.get(firstEnumTarget)).srcMembers != null) {
            break;
          }
        }
        addTargets(0,firstEnumTarget,nEnumTargets,srcMemberIdxes,resultSet,sql);
      }
    }
    final int n=targets.size();
    if (n == 1) {
      return ((Target)targets.get(0)).close();
    }
    List tupleList=new ArrayList();
    Iterator[] iter=new Iterator[n];
    for (int i=0; i < n; i++) {
      Target t=(Target)targets.get(i);
      iter[i]=t.close().iterator();
    }
    while (iter[0].hasNext()) {
      RolapMember[] tuples=new RolapMember[n];
      for (int i=0; i < n; i++) {
        tuples[i]=(RolapMember)iter[i].next();
      }
      tupleList.add(tuples);
    }
    if (nEnumTargets > 0) {
      FunUtil.hierarchize(tupleList,false);
    }
    return tupleList;
  }
 catch (  Throwable e) {
    throw Util.newInternal(e,"String_Node_Str" + targets + "String_Node_Str"+ sql+ "String_Node_Str");
  }
 finally {
    try {
      if (resultSet != null) {
        resultSet.getStatement().close();
        resultSet.close();
      }
    }
 catch (    SQLException e) {
    }
  }
}

Fixed version (ground truth):
public List readTuples(Connection jdbcConnection){
  String sql=makeLevelMembersSql(jdbcConnection);
  ResultSet resultSet=null;
  try {
    resultSet=RolapUtil.executeQuery(jdbcConnection,sql,maxRows,"String_Node_Str" + targets);
    for (Iterator it=targets.iterator(); it.hasNext(); ) {
      ((Target)it.next()).open();
    }
    int limit=MondrianProperties.instance().ResultLimit.get();
    int nFetch=0;
    int nEnumTargets=0;
    for (Iterator it=targets.iterator(); it.hasNext(); ) {
      Target t=(Target)it.next();
      if (t.srcMembers != null) {
        nEnumTargets++;
      }
    }
    int[] srcMemberIdxes=null;
    if (nEnumTargets > 0) {
      srcMemberIdxes=new int[nEnumTargets];
    }
    while (resultSet.next()) {
      if (limit > 0 && limit < ++nFetch) {
        throw MondrianResource.instance().MemberFetchLimitExceeded.ex(new Long(limit));
      }
      if (nEnumTargets == 0) {
        int column=0;
        for (Iterator it=targets.iterator(); it.hasNext(); ) {
          Target t=(Target)it.next();
          t.currMember=null;
          column=t.addRow(resultSet,column);
        }
      }
 else {
        int firstEnumTarget=0;
        for (; firstEnumTarget < targets.size(); firstEnumTarget++) {
          if (((Target)targets.get(firstEnumTarget)).srcMembers != null) {
            break;
          }
        }
        resetCurrMembers();
        addTargets(0,firstEnumTarget,nEnumTargets,srcMemberIdxes,resultSet,sql);
      }
    }
    final int n=targets.size();
    if (n == 1) {
      return ((Target)targets.get(0)).close();
    }
    List tupleList=new ArrayList();
    Iterator[] iter=new Iterator[n];
    for (int i=0; i < n; i++) {
      Target t=(Target)targets.get(i);
      iter[i]=t.close().iterator();
    }
    while (iter[0].hasNext()) {
      RolapMember[] tuples=new RolapMember[n];
      for (int i=0; i < n; i++) {
        tuples[i]=(RolapMember)iter[i].next();
      }
      tupleList.add(tuples);
    }
    if (nEnumTargets > 0) {
      FunUtil.hierarchize(tupleList,false);
    }
    return tupleList;
  }
 catch (  Throwable e) {
    throw Util.newInternal(e,"String_Node_Str" + targets + "String_Node_Str"+ sql+ "String_Node_Str");
  }
 finally {
    try {
      if (resultSet != null) {
        resultSet.getStatement().close();
        resultSet.close();
      }
    }
 catch (    SQLException e) {
    }
  }
}