Program: 73709
Project: 73709
Buggy source:
/** 
 * create query for non-listing report item
 * @param item report item
 * @return a report query
 */
protected BaseQueryDefinition createQuery(ReportItemDesign item,Object parent){
  DesignElementHandle handle=item.getHandle();
  BaseQueryDefinition parentQuery=null;
  if (parent instanceof BaseQueryDefinition) {
    parentQuery=(BaseQueryDefinition)parent;
  }
  if (!(handle instanceof ReportItemHandle)) {
    if (!needQuery(item,parentQuery)) {
      return parentQuery;
    }
    return createSubQuery(item,parentQuery);
  }
  ReportItemHandle designHandle=(ReportItemHandle)handle;
  DataSetHandle dsHandle=designHandle.getDataSet();
  if (dsHandle == null) {
    String dsName=(String)designHandle.getProperty(ReportItemHandle.DATA_SET_PROP);
    if (dsName != null && dsName.length() > 0) {
      context.addException(item.getHandle(),new EngineException(MessageConstants.UNDEFINED_DATASET_ERROR,dsName));
    }
    if (!needQuery(item,parentQuery)) {
      return parentQuery;
    }
    if (parent instanceof CubeQueryDefinition) {
      return null;
    }
    return createSubQuery(item,parentQuery);
  }
  QueryDefinition query=new QueryDefinition(parentQuery);
  query.setDataSetName(dsHandle.getQualifiedName());
  query.getInputParamBindings().addAll(createParamBindings(designHandle.paramBindingsIterator()));
  query.setMaxRows(maxRows);
  Iterator iter=designHandle.columnBindingsIterator();
  while (iter.hasNext()) {
    ComputedColumnHandle binding=(ComputedColumnHandle)iter.next();
    try {
      addColumBinding(query,binding);
    }
 catch (    BirtException ex) {
      context.addException(designHandle,ex);
    }
  }
  addSortAndFilter(item,query);
  return query;
}

Fixed version (ground truth):
/** 
 * create query for non-listing report item
 * @param item report item
 * @return a report query
 */
protected BaseQueryDefinition createQuery(ReportItemDesign item,Object parent){
  DesignElementHandle handle=item.getHandle();
  BaseQueryDefinition parentQuery=null;
  if (parent instanceof BaseQueryDefinition) {
    parentQuery=(BaseQueryDefinition)parent;
  }
  if (!(handle instanceof ReportItemHandle)) {
    if (!needQuery(item,parentQuery)) {
      return parentQuery;
    }
    return createSubQuery(item,parentQuery);
  }
  ReportItemHandle designHandle=(ReportItemHandle)handle;
  DataSetHandle dsHandle=designHandle.getDataSet();
  if (dsHandle == null) {
    String dsName=(String)designHandle.getProperty(ReportItemHandle.DATA_SET_PROP);
    if (dsName != null && dsName.length() > 0) {
      context.addException(item.getHandle(),new EngineException(MessageConstants.UNDEFINED_DATASET_ERROR,dsName));
    }
    if (!needQuery(item,parentQuery)) {
      return parentQuery;
    }
    if (parent instanceof CubeQueryDefinition) {
      return createSubQuery(item,null);
    }
    return createSubQuery(item,parentQuery);
  }
  QueryDefinition query=new QueryDefinition(parentQuery);
  query.setDataSetName(dsHandle.getQualifiedName());
  query.getInputParamBindings().addAll(createParamBindings(designHandle.paramBindingsIterator()));
  query.setMaxRows(maxRows);
  Iterator iter=designHandle.columnBindingsIterator();
  while (iter.hasNext()) {
    ComputedColumnHandle binding=(ComputedColumnHandle)iter.next();
    try {
      addColumBinding(query,binding);
    }
 catch (    BirtException ex) {
      context.addException(designHandle,ex);
    }
  }
  addSortAndFilter(item,query);
  return query;
}