Program: 110652
Project: 110652
Buggy source:
/** 
 * Calculates the set of   {@link Package} objects, represented as source file targets, that dependon the given list of BUILD files and subincludes (other files are filtered out).
 */
@ThreadSafe QueryTaskFuture<Void> getRBuildFiles(Collection<PathFragment> fileIdentifiers,Callback<Target> callback){
  try {
    Collection<SkyKey> files=getSkyKeysForFileFragments(fileIdentifiers);
    Uniquifier<SkyKey> keyUniquifier=new UniquifierImpl<>(SkyKeyKeyExtractor.INSTANCE,1);
    Collection<SkyKey> current=keyUniquifier.unique(graph.getSuccessfulValues(files).keySet());
    Set<SkyKey> resultKeys=CompactHashSet.create();
    while (!current.isEmpty()) {
      Collection<Iterable<SkyKey>> reverseDeps=graph.getReverseDeps(current).values();
      current=new HashSet<>();
      for (      SkyKey rdep : Iterables.concat(reverseDeps)) {
        if (rdep.functionName().equals(SkyFunctions.PACKAGE)) {
          resultKeys.add(rdep);
          if (rdep.equals(PackageValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER))) {
            if (keyUniquifier.unique(rdep)) {
              current.add(rdep);
            }
          }
        }
 else         if (!rdep.functionName().equals(SkyFunctions.PACKAGE_LOOKUP)) {
          if (keyUniquifier.unique(rdep)) {
            current.add(rdep);
          }
        }
      }
      if (resultKeys.size() >= BATCH_CALLBACK_SIZE) {
        for (        Iterable<SkyKey> batch : Iterables.partition(resultKeys,BATCH_CALLBACK_SIZE)) {
          getBuildFileTargetsForPackageKeysAndProcessViaCallback(batch,callback);
        }
        resultKeys.clear();
      }
    }
    getBuildFileTargetsForPackageKeysAndProcessViaCallback(resultKeys,callback);
    return immediateSuccessfulFuture(null);
  }
 catch (  QueryException e) {
    return immediateFailedFuture(e);
  }
catch (  InterruptedException e) {
    return immediateCancelledFuture();
  }
}

Fixed version (ground truth):
/** 
 * Calculates the set of   {@link Package} objects, represented as source file targets, that dependon the given list of BUILD files and subincludes (other files are filtered out).
 */
@ThreadSafe QueryTaskFuture<Void> getRBuildFiles(Collection<PathFragment> fileIdentifiers,Callback<Target> callback){
  try {
    Collection<SkyKey> files=getFileStateKeysForFileFragments(fileIdentifiers);
    Uniquifier<SkyKey> keyUniquifier=new UniquifierImpl<>(SkyKeyKeyExtractor.INSTANCE,1);
    Collection<SkyKey> current=keyUniquifier.unique(graph.getSuccessfulValues(files).keySet());
    Set<SkyKey> resultKeys=CompactHashSet.create();
    while (!current.isEmpty()) {
      Collection<Iterable<SkyKey>> reverseDeps=graph.getReverseDeps(current).values();
      current=new HashSet<>();
      for (      SkyKey rdep : Iterables.concat(reverseDeps)) {
        if (rdep.functionName().equals(SkyFunctions.PACKAGE)) {
          resultKeys.add(rdep);
          if (rdep.equals(PackageValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER))) {
            if (keyUniquifier.unique(rdep)) {
              current.add(rdep);
            }
          }
        }
 else         if (!rdep.functionName().equals(SkyFunctions.PACKAGE_LOOKUP)) {
          if (keyUniquifier.unique(rdep)) {
            current.add(rdep);
          }
        }
      }
      if (resultKeys.size() >= BATCH_CALLBACK_SIZE) {
        for (        Iterable<SkyKey> batch : Iterables.partition(resultKeys,BATCH_CALLBACK_SIZE)) {
          getBuildFileTargetsForPackageKeysAndProcessViaCallback(batch,callback);
        }
        resultKeys.clear();
      }
    }
    getBuildFileTargetsForPackageKeysAndProcessViaCallback(resultKeys,callback);
    return immediateSuccessfulFuture(null);
  }
 catch (  QueryException e) {
    return immediateFailedFuture(e);
  }
catch (  InterruptedException e) {
    return immediateCancelledFuture();
  }
}