Program: 7884
Project: 7884
Buggy source:
@Override public List<Dataset> getDatasetsByApplication(String account,String app) throws MetadataServiceException, TException {
  validateAccount(account);
  Map<String,Dataset> foundDatasets=Maps.newHashMap();
  List<Flow> flows=getFlowsByApplication(account,app);
  for (  Flow flow : flows) {
    List<String> flowDatasets=flow.getDatasets();
    if (flowDatasets == null || flowDatasets.isEmpty()) {
      continue;
    }
    for (    String datasetName : flowDatasets) {
      if (foundDatasets.containsKey(datasetName)) {
        continue;
      }
      Dataset dataset=getDataset(new Account(account),new Dataset(datasetName));
      if (dataset.isExists()) {
        foundDatasets.put(datasetName,dataset);
      }
    }
  }
  List<Query> queries=getQueriesByApplication(account,app);
  for (  Query query : queries) {
    List<String> queryDatasets=query.getDatasets();
    if (queryDatasets == null || queryDatasets.isEmpty()) {
      continue;
    }
    for (    String datasetName : queryDatasets) {
      if (foundDatasets.containsKey(datasetName)) {
        continue;
      }
      Dataset dataset=getDataset(new Account(account),new Dataset(datasetName));
      if (dataset.isExists()) {
        foundDatasets.put(datasetName,dataset);
      }
    }
  }
  List<Mapreduce> mapreduces=getMapreducesByApplication(account,app);
  for (  Mapreduce mapreduce : mapreduces) {
    List<String> mapreduceDatasets=mapreduce.getDatasets();
    if (mapreduceDatasets == null || mapreduceDatasets.isEmpty())     continue;
    for (    String datasetName : mapreduceDatasets) {
      if (foundDatasets.containsKey(datasetName))       continue;
      Dataset dataset=getDataset(new Account(account),new Dataset(datasetName));
      if (dataset.isExists()) {
        foundDatasets.put(datasetName,dataset);
      }
    }
  }
  List<Dataset> datasets=Lists.newArrayList();
  for (  Dataset dataset : foundDatasets.values()) {
    datasets.add(dataset);
  }
  return datasets;
}

Fixed version (ground truth):
@Override public List<Dataset> getDatasetsByApplication(String account,String app) throws MetadataServiceException, TException {
  validateAccount(account);
  Map<String,Dataset> foundDatasets=Maps.newHashMap();
  List<Flow> flows=getFlowsByApplication(account,app);
  for (  Flow flow : flows) {
    List<String> flowDatasets=flow.getDatasets();
    if (flowDatasets == null || flowDatasets.isEmpty()) {
      continue;
    }
    for (    String datasetName : flowDatasets) {
      if (foundDatasets.containsKey(datasetName)) {
        continue;
      }
      Dataset dataset=getDataset(new Account(account),new Dataset(datasetName));
      if (dataset.isExists()) {
        foundDatasets.put(datasetName,dataset);
      }
    }
  }
  List<Query> queries=getQueriesByApplication(account,app);
  for (  Query query : queries) {
    List<String> queryDatasets=query.getDatasets();
    if (queryDatasets == null || queryDatasets.isEmpty()) {
      continue;
    }
    for (    String datasetName : queryDatasets) {
      if (foundDatasets.containsKey(datasetName)) {
        continue;
      }
      Dataset dataset=getDataset(new Account(account),new Dataset(datasetName));
      if (dataset.isExists()) {
        foundDatasets.put(datasetName,dataset);
      }
    }
  }
  List<Mapreduce> mapreduces=getMapreducesByApplication(account,app);
  for (  Mapreduce mapreduce : mapreduces) {
    List<String> mapreduceDatasets=mapreduce.getDatasets();
    if (mapreduceDatasets == null || mapreduceDatasets.isEmpty()) {
      continue;
    }
    for (    String datasetName : mapreduceDatasets) {
      if (foundDatasets.containsKey(datasetName)) {
        continue;
      }
      Dataset dataset=getDataset(new Account(account),new Dataset(datasetName));
      if (dataset.isExists()) {
        foundDatasets.put(datasetName,dataset);
      }
    }
  }
  List<Dataset> datasets=Lists.newArrayList();
  for (  Dataset dataset : foundDatasets.values()) {
    datasets.add(dataset);
  }
  return datasets;
}