Program: 65118
Project: 65118
Buggy source:
/** 
 * prepare for transient query
 * @param sessionContext
 * @param dataEngine
 * @param handle
 * @param queryDefn
 * @throws BirtException
 */
public static void prepareForTransientQuery(DataSessionContext dContext,DataEngineImpl dataEngine,DataSetHandle handle,IQueryDefinition queryDefn,IDataQueryDefinition[] registedQueries) throws BirtException {
  IBaseDataSetDesign design=null;
  if (handle == null) {
    if (queryDefn.getDataSetName() == null) {
      if (queryDefn.getSourceQuery() != null && queryDefn.getSourceQuery() instanceof IQueryDefinition)       design=dataEngine.getDataSetDesign(((IQueryDefinition)queryDefn.getSourceQuery()).getDataSetName());
    }
 else     design=dataEngine.getDataSetDesign(queryDefn.getDataSetName());
  }
 else {
    design=dataEngine.getDataSetDesign(handle.getQualifiedName());
  }
  final IDataSetInterceptor dataSetInterceptor=DataSetInterceptorFinder.find(design);
  if (dataSetInterceptor != null) {
    dataSetInterceptor.preDefineDataSet(dContext,dataEngine.getDataSourceDesign(design.getDataSourceName()),design,queryDefn,registedQueries);
    dataEngine.addShutdownListener(new IShutdownListener(){
      public void dataEngineShutdown(){
        try {
          dataSetInterceptor.close();
        }
 catch (        BirtException e) {
        }
      }
    }
);
    return;
  }
  if (handle instanceof JointDataSetHandle) {
    JointDataSetHandle jointDataSet=(JointDataSetHandle)handle;
    Iterator iter=jointDataSet.dataSetsIterator();
    while (iter.hasNext()) {
      DataSetHandle childDataSet=(DataSetHandle)iter.next();
      if (childDataSet != null) {
        prepareForTransientQuery(dContext,dataEngine,childDataSet,queryDefn,registedQueries);
      }
    }
  }
  if (handle instanceof DerivedDataSetHandle) {
    List<DataSetHandle> inputDataSet=((DerivedDataSetHandle)handle).getInputDataSets();
    for (int i=0; i < inputDataSet.size(); i++) {
      prepareForTransientQuery(dContext,dataEngine,inputDataSet.get(i),queryDefn,registedQueries);
    }
  }
}

Fixed version (ground truth):
/** 
 * prepare for transient query
 * @param sessionContext
 * @param dataEngine
 * @param handle
 * @param queryDefn
 * @throws BirtException
 */
public static void prepareForTransientQuery(DataSessionContext dContext,DataEngineImpl dataEngine,DataSetHandle handle,IQueryDefinition queryDefn,IDataQueryDefinition[] registedQueries) throws BirtException {
  IBaseDataSetDesign design=null;
  if (handle == null) {
    if (queryDefn.getDataSetName() == null) {
      if (queryDefn.getSourceQuery() != null && queryDefn.getSourceQuery() instanceof IQueryDefinition)       design=dataEngine.getDataSetDesign(((IQueryDefinition)queryDefn.getSourceQuery()).getDataSetName());
    }
 else     design=dataEngine.getDataSetDesign(queryDefn.getDataSetName());
  }
 else {
    design=dataEngine.getDataSetDesign(handle.getQualifiedName());
  }
  final IDataSetInterceptor dataSetInterceptor=DataSetInterceptorFinder.find(design);
  if (dataSetInterceptor != null) {
    dataSetInterceptor.preDefineDataSet(dataEngine.getDataSourceDesign(design.getDataSourceName()),design,queryDefn,registedQueries,dContext,dataEngine.getSession().getTempDir());
    dataEngine.addShutdownListener(new IShutdownListener(){
      public void dataEngineShutdown(){
        try {
          dataSetInterceptor.close();
        }
 catch (        BirtException e) {
        }
      }
    }
);
    return;
  }
  if (handle instanceof JointDataSetHandle) {
    JointDataSetHandle jointDataSet=(JointDataSetHandle)handle;
    Iterator iter=jointDataSet.dataSetsIterator();
    while (iter.hasNext()) {
      DataSetHandle childDataSet=(DataSetHandle)iter.next();
      if (childDataSet != null) {
        prepareForTransientQuery(dContext,dataEngine,childDataSet,queryDefn,registedQueries);
      }
    }
  }
  if (handle instanceof DerivedDataSetHandle) {
    List<DataSetHandle> inputDataSet=((DerivedDataSetHandle)handle).getInputDataSets();
    for (int i=0; i < inputDataSet.size(); i++) {
      prepareForTransientQuery(dContext,dataEngine,inputDataSet.get(i),queryDefn,registedQueries);
    }
  }
}