Program: 73256
Project: 73256
Buggy source:
private IExtractionResults extractByInstanceID(InstanceID instanceId) throws BirtException {
  InstanceID iid=instanceId;
  while (iid != null) {
    long id=iid.getComponentID();
    ReportItemDesign design=(ReportItemDesign)report.getReportItemByID(id);
    IDataQueryDefinition dataQuery=design.getQuery();
    if (dataQuery != null) {
      if (!(dataQuery instanceof IBaseQueryDefinition)) {
        return null;
      }
      IBaseQueryDefinition query=(IBaseQueryDefinition)dataQuery;
      if (filterExpressions != null) {
        query=cloneQuery(query);
        for (int i=0; i < filterExpressions.length; i++) {
          query.getFilters().add(filterExpressions[i]);
        }
      }
      while (iid != null) {
        DataID dataId=iid.getDataID();
        if (dataId != null) {
          DataSetID dataSetId=dataId.getDataSetID();
          long rowId=dataId.getRowID();
          IResultIterator dataIter=executeSubQuery(dataSetId,rowId,(ISubqueryDefinition)query);
          IResultMetaData metaData=getMetaDateByInstanceID(instanceId);
          if (dataIter != null && metaData != null) {
            return new ExtractionResults(dataIter,metaData,this.selectedColumns);
          }
          return null;
        }
        iid=iid.getParentID();
      }
      return null;
    }
    iid=iid.getParentID();
  }
  return null;
}

Fixed version (ground truth):
private IExtractionResults extractByInstanceID(InstanceID instanceId) throws BirtException {
  InstanceID iid=instanceId;
  while (iid != null) {
    long id=iid.getComponentID();
    ReportItemDesign design=(ReportItemDesign)report.getReportItemByID(id);
    IDataQueryDefinition dataQuery=design.getQuery();
    if (dataQuery != null) {
      if (!(dataQuery instanceof IBaseQueryDefinition)) {
        return null;
      }
      IBaseQueryDefinition query=(IBaseQueryDefinition)dataQuery;
      String queryId=(String)query2QueryIdMapping.get(query);
      if (filterExpressions != null) {
        query=cloneQuery(query);
        for (int i=0; i < filterExpressions.length; i++) {
          query.getFilters().add(filterExpressions[i]);
        }
      }
      if (query instanceof IQueryDefinition) {
        while (iid != null) {
          DataID dataId=iid.getDataID();
          if (dataId != null) {
            DataSetID dataSetId=dataId.getDataSetID();
            long rowId=dataId.getRowID();
            IResultIterator dataIter=executeQuery(dataSetId.toString(),rowId,queryId,(IQueryDefinition)query);
            IResultMetaData metaData=getMetaDateByInstanceID(instanceId);
            if (dataIter != null && metaData != null) {
              return new ExtractionResults(dataIter,metaData,this.selectedColumns);
            }
            return null;
          }
          iid=iid.getParentID();
        }
        IResultIterator dataIter=executeQuery(null,-1,queryId,(QueryDefinition)query);
        IResultMetaData metaData=getMetaDateByInstanceID(instanceId);
        if (dataIter != null && metaData != null) {
          return new ExtractionResults(dataIter,metaData,this.selectedColumns);
        }
        return null;
      }
 else {
        while (iid != null) {
          DataID dataId=iid.getDataID();
          if (dataId != null) {
            DataSetID dataSetId=dataId.getDataSetID();
            long rowId=dataId.getRowID();
            IResultIterator dataIter=executeSubQuery(dataSetId,rowId,(ISubqueryDefinition)query);
            IResultMetaData metaData=getMetaDateByInstanceID(instanceId);
            if (dataIter != null && metaData != null) {
              return new ExtractionResults(dataIter,metaData,this.selectedColumns);
            }
            return null;
          }
          iid=iid.getParentID();
        }
      }
    }
    iid=iid.getParentID();
  }
  return null;
}