Program: 65117
Project: 65117
Buggy source:
public static void defineDataSourceAndDataSet(DataSetHandle dataSet,DataEngine dataEngine,IModelAdapter modelAdaptor,QueryExecutionHelper.DataSetHandleProcessContext context) throws BirtException {
  if (dataSet == null)   return;
  DataSourceHandle dataSource=dataSet.getDataSource();
  if (dataSource != null && ((DataEngineImpl)dataEngine).getDataSourceRuntime(dataSource.getQualifiedName()) == null) {
    dataEngine.defineDataSource(modelAdaptor.adaptDataSource(dataSource));
  }
  if (dataSet instanceof JointDataSetHandle) {
    JointDataSetHandle jointDataSet=(JointDataSetHandle)dataSet;
    Iterator iter=jointDataSet.dataSetsIterator();
    while (iter.hasNext()) {
      DataSetHandle childDataSet=(DataSetHandle)iter.next();
      if (childDataSet != null) {
        DataSourceHandle childDataSource=childDataSet.getDataSource();
        if (childDataSource != null) {
          dataEngine.defineDataSource(modelAdaptor.adaptDataSource(childDataSource));
        }
        defineDataSourceAndDataSet(childDataSet,dataEngine,modelAdaptor,context);
      }
    }
  }
  if (dataSet instanceof DerivedDataSetHandle) {
    List inputDataSet=((DerivedDataSetHandle)dataSet).getInputDataSets();
    for (int i=0; i < inputDataSet.size(); i++) {
      defineDataSourceAndDataSet((DataSetHandle)inputDataSet.get(i),dataEngine,modelAdaptor,context);
    }
  }
  IBaseDataSetDesign design=((DataEngineImpl)dataEngine).getDataSetDesign(dataSet.getQualifiedName());
  if (design == null) {
    design=modelAdaptor.adaptDataSet(dataSet);
    dataEngine.defineDataSet(design);
  }
  if (context != null)   context.process(design,dataSet);
}

Fixed version (ground truth):
public static void defineDataSourceAndDataSet(DataSetHandle dataSet,DataEngine dataEngine,IModelAdapter modelAdaptor,QueryExecutionHelper.DataSetHandleProcessContext context) throws BirtException {
  if (dataSet == null)   return;
  DataSourceHandle dataSource=dataSet.getDataSource();
  if (dataSource != null && ((DataEngineImpl)dataEngine).getDataSourceRuntime(dataSource.getQualifiedName()) == null) {
    dataEngine.defineDataSource(modelAdaptor.adaptDataSource(dataSource));
  }
  if (dataSet instanceof JointDataSetHandle) {
    JointDataSetHandle jointDataSet=(JointDataSetHandle)dataSet;
    Iterator iter=jointDataSet.dataSetsIterator();
    while (iter.hasNext()) {
      DataSetHandle childDataSet=(DataSetHandle)iter.next();
      if (childDataSet != null) {
        DataSourceHandle childDataSource=childDataSet.getDataSource();
        if (childDataSource != null) {
          dataEngine.defineDataSource(modelAdaptor.adaptDataSource(childDataSource));
        }
        defineDataSourceAndDataSet(childDataSet,dataEngine,modelAdaptor,context);
      }
    }
  }
 else   if (dataSet instanceof DerivedDataSetHandle) {
    List inputDataSet=((DerivedDataSetHandle)dataSet).getInputDataSets();
    for (int i=0; i < inputDataSet.size(); i++) {
      defineDataSourceAndDataSet((DataSetHandle)inputDataSet.get(i),dataEngine,modelAdaptor,context);
    }
  }
  IBaseDataSetDesign design=((DataEngineImpl)dataEngine).getDataSetDesign(dataSet.getQualifiedName());
  if (design == null) {
    design=modelAdaptor.adaptDataSet(dataSet);
    dataEngine.defineDataSet(design);
  }
  if (context != null)   context.process(design,dataSet);
}