Program: 65252
Project: 65252
Buggy source:
/** 
 * @param dataEngine
 * @param queryDefns
 * @throws DataException
 */
void populateCachedDataSets(DataEngineImpl dataEngine,IDataQueryDefinition[] qds) throws DataException {
  if (qds != null) {
    queryDefns.addAll(Arrays.asList(qds));
    List temp=new ArrayList();
    List temp2=new ArrayList();
    this.cachedDataSetNames.clear();
    for (    IDataQueryDefinition query : queryDefns) {
      if (query instanceof IQueryDefinition) {
        IQueryDefinition qd=(IQueryDefinition)query;
        String dataSetName=qd.getDataSetName();
        if (dataSetName != null) {
          IBaseDataSetDesign design=dataEngine.getDataSetDesign(dataSetName);
          if (design instanceof ICacheable)           this.populateDataSetNames(dataEngine.getDataSetDesign(dataSetName),dataEngine,temp2);
          if (qd.getParentQuery() != null && qd.getInputParamBindings().size() == 0) {
            for (int i=0; i < temp2.size(); i++) {
              if (((BaseDataSetDesign)dataEngine.getDataSetDesign(temp2.get(i).toString())).needCache())               this.cachedDataSetNames.add(temp2.get(i));
            }
          }
          for (int i=0; i < temp2.size(); i++) {
            if (((BaseDataSetDesign)dataEngine.getDataSetDesign(temp2.get(i).toString())).needCache()) {
              temp.add(temp2.get(i));
            }
          }
        }
      }
      temp2.clear();
    }
    Set tempSet=new HashSet();
    for (int i=0; i < temp.size(); i++) {
      if (tempSet.contains(temp.get(i)))       this.cachedDataSetNames.add(temp.get(i));
 else       tempSet.add(temp.get(i));
    }
    for (    IDataQueryDefinition query : queryDefns) {
      if (query instanceof IQueryDefinition) {
        IQueryDefinition q=(IQueryDefinition)query;
        String dataSetName=q.getDataSetName();
        if (dataSetName != null && this.cachedDataSetNames.contains(dataSetName)) {
          IBaseDataSetDesign dataSet=dataEngine.getDataSetDesign(dataSetName);
          if (dataSet instanceof IOdaDataSetDesign) {
            IBaseDataSourceDesign source=dataEngine.getDataSourceDesign(dataSet.getDataSourceName());
            boolean supportInExtensionOnly=FilterPrepareUtil.containsExternalFilter(((IQueryDefinition)query).getFilters(),((IOdaDataSetDesign)dataSet).getExtensionID(),((IOdaDataSourceDesign)source).getExtensionID());
            if (supportInExtensionOnly) {
              this.cachedDataSetNames.remove(dataSet.getName());
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param dataEngine
 * @param queryDefns
 * @throws DataException
 */
void populateCachedDataSets(DataEngineImpl dataEngine,IDataQueryDefinition[] qds) throws DataException {
  if (qds != null) {
    queryDefns.addAll(Arrays.asList(qds));
    List temp=new ArrayList();
    List temp2=new ArrayList();
    this.cachedDataSetNames.clear();
    for (    IDataQueryDefinition query : queryDefns) {
      if (query instanceof IQueryDefinition) {
        IQueryDefinition qd=(IQueryDefinition)query;
        String dataSetName=qd.getDataSetName();
        if (dataSetName != null) {
          IBaseDataSetDesign design=dataEngine.getDataSetDesign(dataSetName);
          if (design instanceof ICacheable)           DataSetDesignHelper.populateDataSetNames(dataEngine.getDataSetDesign(dataSetName),dataEngine,temp2);
          if (qd.getParentQuery() != null && qd.getInputParamBindings().size() == 0) {
            for (int i=0; i < temp2.size(); i++) {
              if (((BaseDataSetDesign)dataEngine.getDataSetDesign(temp2.get(i).toString())).needCache())               this.cachedDataSetNames.add(temp2.get(i));
            }
          }
          for (int i=0; i < temp2.size(); i++) {
            if (((BaseDataSetDesign)dataEngine.getDataSetDesign(temp2.get(i).toString())).needCache()) {
              temp.add(temp2.get(i));
            }
          }
        }
      }
      temp2.clear();
    }
    Set tempSet=new HashSet();
    for (int i=0; i < temp.size(); i++) {
      if (tempSet.contains(temp.get(i)))       this.cachedDataSetNames.add(temp.get(i));
 else       tempSet.add(temp.get(i));
    }
    for (    IDataQueryDefinition query : queryDefns) {
      if (query instanceof IQueryDefinition) {
        IQueryDefinition q=(IQueryDefinition)query;
        String dataSetName=q.getDataSetName();
        if (dataSetName != null && this.cachedDataSetNames.contains(dataSetName)) {
          IBaseDataSetDesign dataSet=dataEngine.getDataSetDesign(dataSetName);
          if (dataSet instanceof IOdaDataSetDesign) {
            IBaseDataSourceDesign source=dataEngine.getDataSourceDesign(dataSet.getDataSourceName());
            boolean supportInExtensionOnly=FilterPrepareUtil.containsExternalFilter(((IQueryDefinition)query).getFilters(),((IOdaDataSetDesign)dataSet).getExtensionID(),((IOdaDataSourceDesign)source).getExtensionID());
            if (supportInExtensionOnly) {
              this.cachedDataSetNames.remove(dataSet.getName());
            }
          }
        }
      }
    }
  }
}