Program: 65910
Project: 65910
Buggy source:
/** 
 * Create query definition by report item handle.
 * @param handle
 * @param parent
 * @return
 * @throws BirtException
 */
IDataQueryDefinition createQuery(ExtendedItemHandle handle,IDataQueryDefinition parent) throws BirtException {
  IModelAdapter modelAdapter=context.getDataRequestSession().getModelAdaptor();
  if (handle.getDataSet() != null || (handle.getCube() == null && parent instanceof IBaseQueryDefinition)) {
    ReportItemHandle itemHandle=null;
    if (ChartItemUtil.isChartInheritGroups(handle)) {
      DesignElementHandle container=handle.getContainer();
      while (container != null) {
        if (container instanceof ListingHandle) {
          itemHandle=(ListingHandle)container;
          return new ChartSharingQueryHelper(handle,cm,modelAdapter).createQuery(parent);
        }
        container=container.getContainer();
      }
    }
 else {
      itemHandle=ChartItemUtil.getReportItemReference(handle);
    }
    if (itemHandle != null) {
      return new ChartSharingQueryHelper(itemHandle,cm,modelAdapter).createQuery(parent);
    }
    return new ChartBaseQueryHelper(handle,cm,modelAdapter).createBaseQuery(parent);
  }
 else   if (handle.getCube() != null || parent instanceof ICubeQueryDefinition) {
    if (handle.getContainer() instanceof MultiViewsHandle) {
      ExtendedItemHandle bindingHandle=(ExtendedItemHandle)ChartItemUtil.getReportItemReference(handle);
      IDataQueryDefinition cubeQuery=CrosstabQueryUtil.createCubeQuery((CrosstabReportItemHandle)bindingHandle.getReportItem(),parent,true,true,true,true,true,true);
      return cubeQuery;
    }
    return ChartReportItemUtil.instanceCubeQueryHelper(handle,cm,modelAdapter).createCubeQuery(parent);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Create query definition by report item handle.
 * @param handle
 * @param parent
 * @return
 * @throws BirtException
 */
IDataQueryDefinition createQuery(ExtendedItemHandle handle,IDataQueryDefinition parent) throws BirtException {
  IModelAdapter modelAdapter=context.getDataRequestSession().getModelAdaptor();
  if (handle.getDataSet() != null || (handle.getCube() == null && parent instanceof IBaseQueryDefinition)) {
    ReportItemHandle itemHandle=null;
    if (ChartItemUtil.isChartInheritGroups(handle)) {
      DesignElementHandle container=handle.getContainer();
      while (container != null) {
        if (container instanceof ListingHandle) {
          itemHandle=(ListingHandle)container;
          return new ChartSharingQueryHelper(handle,cm,modelAdapter).createQuery(parent);
        }
        container=container.getContainer();
      }
    }
 else {
      itemHandle=ChartItemUtil.getReportItemReference(handle);
    }
    if (itemHandle != null) {
      return new ChartSharingQueryHelper(itemHandle,cm,modelAdapter).createQuery(parent);
    }
    return new ChartBaseQueryHelper(handle,cm,modelAdapter).createBaseQuery(parent);
  }
 else   if (handle.getCube() != null || parent instanceof ICubeQueryDefinition) {
    if (handle.getContainer() instanceof MultiViewsHandle) {
      ExtendedItemHandle bindingHandle=(ExtendedItemHandle)ChartItemUtil.getReportItemReference(handle);
      IDataQueryDefinition cubeQuery=CrosstabQueryUtil.createCubeQuery((CrosstabReportItemHandle)bindingHandle.getReportItem(),parent,modelAdapter,true,true,true,true,true,true);
      return cubeQuery;
    }
    return ChartReportItemUtil.instanceCubeQueryHelper(handle,cm,modelAdapter).createCubeQuery(parent);
  }
  return null;
}