Program: 110573
Project: 110573
Buggy source:
@Override protected Visit getVisitResult(Iterable<Pair<SkyKey,SkyKey>> keys) throws InterruptedException {
  Collection<SkyKey> filteredKeys=new ArrayList<>();
  Map<SkyKey,Collection<SkyKey>> reverseDepsMap=Maps.newHashMap();
  for (  Pair<SkyKey,SkyKey> reverseDepPair : keys) {
    if (reverseDepPair.first == null) {
      filteredKeys.add(Preconditions.checkNotNull(reverseDepPair.second));
      continue;
    }
    reverseDepsMap.computeIfAbsent(reverseDepPair.first,k -> new LinkedList<SkyKey>());
    reverseDepsMap.get(reverseDepPair.first).add(reverseDepPair.second);
  }
  Multimap<SkyKey,SkyKey> packageKeyToTargetKeyMap=env.makePackageKeyToTargetKeyMap(Iterables.concat(reverseDepsMap.values()));
  Set<PackageIdentifier> pkgIdsNeededForTargetification=packageKeyToTargetKeyMap.keySet().stream().map(SkyQueryEnvironment.PACKAGE_SKYKEY_TO_PACKAGE_IDENTIFIER).collect(toImmutableSet());
  packageSemaphore.acquireAll(pkgIdsNeededForTargetification);
  try {
    if (!reverseDepsMap.isEmpty()) {
      Collection<Target> filteredTargets=env.filterRawReverseDepsOfTransitiveTraversalKeys(reverseDepsMap,packageKeyToTargetKeyMap);
      filteredTargets.stream().map(SkyQueryEnvironment.TARGET_TO_SKY_KEY).forEachOrdered(filteredKeys::add);
    }
  }
  finally {
    packageSemaphore.releaseAll(pkgIdsNeededForTargetification);
  }
  Map<SkyKey,Iterable<SkyKey>> unfilteredReverseDeps=env.graph.getReverseDeps(filteredKeys);
  ImmutableList.Builder<Pair<SkyKey,SkyKey>> builder=ImmutableList.builder();
  for (  Map.Entry<SkyKey,Iterable<SkyKey>> rdeps : unfilteredReverseDeps.entrySet()) {
    for (    SkyKey rdep : rdeps.getValue()) {
      Label label=SkyQueryEnvironment.SKYKEY_TO_LABEL.apply(rdep);
      if (label != null) {
        builder.add(Pair.of(rdeps.getKey(),rdep));
      }
    }
  }
  return new Visit(filteredKeys,builder.build());
}

Fixed version (ground truth):
@Override protected Visit getVisitResult(Iterable<DepAndRdep> depAndRdeps) throws InterruptedException {
  Collection<SkyKey> filteredUniqueKeys=new ArrayList<>();
  Map<SkyKey,Collection<SkyKey>> reverseDepsMap=Maps.newHashMap();
  for (  DepAndRdep depAndRdep : depAndRdeps) {
    if (depAndRdep.dep == null && validRdepUniquifier.unique(depAndRdep.rdep)) {
      filteredUniqueKeys.add(depAndRdep.rdep);
      continue;
    }
    reverseDepsMap.computeIfAbsent(depAndRdep.dep,k -> new LinkedList<SkyKey>());
    reverseDepsMap.get(depAndRdep.dep).add(depAndRdep.rdep);
  }
  Multimap<SkyKey,SkyKey> packageKeyToTargetKeyMap=env.makePackageKeyToTargetKeyMap(Iterables.concat(reverseDepsMap.values()));
  Set<PackageIdentifier> pkgIdsNeededForTargetification=packageKeyToTargetKeyMap.keySet().stream().map(SkyQueryEnvironment.PACKAGE_SKYKEY_TO_PACKAGE_IDENTIFIER).collect(toImmutableSet());
  packageSemaphore.acquireAll(pkgIdsNeededForTargetification);
  try {
    if (!reverseDepsMap.isEmpty()) {
      Collection<Target> filteredTargets=env.filterRawReverseDepsOfTransitiveTraversalKeys(reverseDepsMap,packageKeyToTargetKeyMap);
      filteredTargets.stream().map(SkyQueryEnvironment.TARGET_TO_SKY_KEY).forEachOrdered(rdep -> {
        if (validRdepUniquifier.unique(rdep)) {
          filteredUniqueKeys.add(rdep);
        }
      }
);
    }
  }
  finally {
    packageSemaphore.releaseAll(pkgIdsNeededForTargetification);
  }
  Map<SkyKey,Iterable<SkyKey>> unfilteredReverseDeps=env.graph.getReverseDeps(filteredUniqueKeys);
  ImmutableList.Builder<DepAndRdep> builder=ImmutableList.builder();
  for (  Map.Entry<SkyKey,Iterable<SkyKey>> rdeps : unfilteredReverseDeps.entrySet()) {
    for (    SkyKey rdep : rdeps.getValue()) {
      Label label=SkyQueryEnvironment.SKYKEY_TO_LABEL.apply(rdep);
      if (label != null) {
        builder.add(new DepAndRdep(rdeps.getKey(),rdep));
      }
    }
  }
  return new Visit(filteredUniqueKeys,builder.build());
}