Program: 73254
Project: 73254
Buggy source:
public Object visitExtendedItem(ExtendedItemDesign item,Object value){
  ExtendedItemHandle handle=(ExtendedItemHandle)item.getHandle();
  ReportItemHandle referenceHandle=handle.getDataBindingReference();
  if (referenceHandle != null) {
    IDataQueryDefinition[] queries=report.getQueryByReportHandle(referenceHandle);
    if (queries != null && queries.length > 0) {
      for (int i=0; i < queries.length; i++) {
        IDataQueryDefinition referenceQuery=queries[i];
        if (referenceQuery instanceof BaseQueryDefinition) {
          ((BaseQueryDefinition)referenceQuery).setCacheQueryResults(true);
        }
 else         if (referenceQuery instanceof ICubeQueryDefinition) {
          ((ICubeQueryDefinition)referenceQuery).setCacheQueryResults(true);
        }
      }
      IDataQueryDefinition query=queries[0];
      if (query instanceof IBaseQueryDefinition) {
        try {
          transformExpressions(item,(IBaseQueryDefinition)query);
        }
 catch (        BirtException ex) {
          context.addException(item.getHandle(),ex);
        }
      }
      return queries;
    }
 else {
      registerUnresolvedQueryReference(item);
      return null;
    }
  }
  String tagName=handle.getExtensionName();
  IReportItemQuery itemQuery=ExtensionManager.getInstance().createQueryItem(tagName);
  IDataQueryDefinition[] queries=null;
  IDataQueryDefinition parentQuery=(IDataQueryDefinition)value;
  if (itemQuery != null) {
    try {
      itemQuery.setModelObject(handle);
      itemQuery.setQueryContext(queryContext);
      queries=itemQuery.createReportQueries(parentQuery);
    }
 catch (    BirtException ex) {
      context.addException(handle,ex);
    }
    if (queries != null) {
      if (queries.length > 0) {
        IDataQueryDefinition query=queries[0];
        if (query instanceof IBaseQueryDefinition) {
          try {
            IBaseQueryDefinition baseQuery=(IBaseQueryDefinition)query;
            transformExpressions(item,baseQuery,null);
            if (query instanceof ISubqueryDefinition) {
              ISubqueryDefinition subQuery=(ISubqueryDefinition)query;
              String name=String.valueOf(item.getID());
              queries[0]=changeSubqueryName(subQuery,name);
            }
          }
 catch (          BirtException ex) {
            context.addException(handle,ex);
          }
        }
      }
      return queries;
    }
  }
  BaseQueryDefinition query=createQuery(item,parentQuery);
  try {
    transformExpressions(item,query);
  }
 catch (  BirtException ex) {
    context.addException(item.getHandle(),ex);
  }
  return getResultQuery(query,value);
}

Fixed version (ground truth):
public Object visitExtendedItem(ExtendedItemDesign item,Object value){
  ExtendedItemHandle handle=(ExtendedItemHandle)item.getHandle();
  ReportItemHandle referenceHandle=handle.getDataBindingReference();
  if (referenceHandle != null) {
    IDataQueryDefinition[] queries=report.getQueryByReportHandle(referenceHandle);
    if (queries != null && queries.length > 0) {
      for (int i=0; i < queries.length; i++) {
        IDataQueryDefinition referenceQuery=queries[i];
        if (referenceQuery instanceof BaseQueryDefinition) {
          ((BaseQueryDefinition)referenceQuery).setCacheQueryResults(true);
        }
 else         if (referenceQuery instanceof ICubeQueryDefinition) {
          ((ICubeQueryDefinition)referenceQuery).setCacheQueryResults(true);
        }
      }
      IDataQueryDefinition query=queries[0];
      if (query instanceof IBaseQueryDefinition) {
        try {
          transformExpressions(item,(IBaseQueryDefinition)query);
        }
 catch (        BirtException ex) {
          context.addException(item.getHandle(),ex);
        }
      }
      return queries;
    }
 else {
      registerUnresolvedQueryReference(item);
      return null;
    }
  }
  String tagName=handle.getExtensionName();
  IReportItemQuery itemQuery=ExtensionManager.getInstance().createQueryItem(tagName);
  IDataQueryDefinition[] queries=null;
  IDataQueryDefinition parentQuery=(IDataQueryDefinition)value;
  if (itemQuery != null) {
    try {
      itemQuery.setModelObject(handle);
      itemQuery.setQueryContext(queryContext);
      queries=itemQuery.createReportQueries(parentQuery);
    }
 catch (    BirtException ex) {
      context.addException(handle,ex);
    }
    if (queries != null) {
      if (queries.length > 0) {
        IDataQueryDefinition query=queries[0];
        if (query instanceof IBaseQueryDefinition) {
          try {
            IBaseQueryDefinition baseQuery=(IBaseQueryDefinition)query;
            baseQuery.setMaxRows(maxRows);
            transformExpressions(item,baseQuery,null);
            if (query instanceof ISubqueryDefinition) {
              ISubqueryDefinition subQuery=(ISubqueryDefinition)query;
              String name=String.valueOf(item.getID());
              queries[0]=changeSubqueryName(subQuery,name);
            }
          }
 catch (          BirtException ex) {
            context.addException(handle,ex);
          }
        }
      }
      return queries;
    }
  }
  BaseQueryDefinition query=createQuery(item,parentQuery);
  try {
    transformExpressions(item,query);
  }
 catch (  BirtException ex) {
    context.addException(item.getHandle(),ex);
  }
  return getResultQuery(query,value);
}