Program: 110494
Project: 110494
Buggy source:
@Override protected Visit getVisitResult(Iterable<DepAndRdep> depAndRdeps) throws QueryException, InterruptedException {
  Collection<SkyKey> validRdeps=new ArrayList<>();
  Multimap<SkyKey,SkyKey> reverseDepMultimap=ArrayListMultimap.create();
  for (  DepAndRdep depAndRdep : depAndRdeps) {
    if (depAndRdep.dep == null) {
      validRdeps.add(depAndRdep.rdep);
    }
 else {
      reverseDepMultimap.put(depAndRdep.dep,depAndRdep.rdep);
    }
  }
  Multimap<SkyKey,SkyKey> packageKeyToTargetKeyMap=env.makePackageKeyToTargetKeyMap(Iterables.concat(reverseDepMultimap.values()));
  Set<PackageIdentifier> pkgIdsNeededForTargetification=packageKeyToTargetKeyMap.keySet().stream().map(SkyQueryEnvironment.PACKAGE_SKYKEY_TO_PACKAGE_IDENTIFIER).collect(toImmutableSet());
  packageSemaphore.acquireAll(pkgIdsNeededForTargetification);
  try {
    if (!reverseDepMultimap.isEmpty()) {
      Collection<Target> filteredTargets=env.filterRawReverseDepsOfTransitiveTraversalKeys(reverseDepMultimap.asMap(),packageKeyToTargetKeyMap);
      filteredTargets.stream().map(SkyQueryEnvironment.TARGET_TO_SKY_KEY).forEachOrdered(validRdeps::add);
    }
  }
  finally {
    packageSemaphore.releaseAll(pkgIdsNeededForTargetification);
  }
  ImmutableList.Builder<SkyKey> uniqueValidRdepsbuilder=ImmutableList.builder();
  for (  SkyKey rdep : validRdeps) {
    if (validRdepUniquifier.unique(rdep)) {
      uniqueValidRdepsbuilder.add(rdep);
    }
  }
  ImmutableList<SkyKey> uniqueValidRdeps=uniqueValidRdepsbuilder.build();
  ImmutableList.Builder<DepAndRdep> depAndRdepsToVisitBuilder=ImmutableList.builder();
  env.graph.getReverseDeps(uniqueValidRdeps).entrySet().forEach(reverseDepsEntry -> depAndRdepsToVisitBuilder.addAll(Iterables.transform(Iterables.filter(reverseDepsEntry.getValue(),Predicates.and(SkyQueryEnvironment.IS_TTV,universe)),rdep -> new DepAndRdep(reverseDepsEntry.getKey(),rdep))));
  return new Visit(uniqueValidRdeps,depAndRdepsToVisitBuilder.build());
}

Fixed version (ground truth):
@Override protected Visit getVisitResult(Iterable<DepAndRdep> depAndRdeps) throws QueryException, InterruptedException {
  Collection<SkyKey> validRdeps=new ArrayList<>();
  Multimap<SkyKey,SkyKey> reverseDepMultimap=ArrayListMultimap.create();
  for (  DepAndRdep depAndRdep : depAndRdeps) {
    if (depAndRdep.dep == null) {
      validRdeps.add(depAndRdep.rdep);
    }
 else {
      reverseDepMultimap.put(depAndRdep.dep,depAndRdep.rdep);
    }
  }
  Multimap<SkyKey,SkyKey> packageKeyToTargetKeyMap=env.makePackageKeyToTargetKeyMap(Iterables.concat(reverseDepMultimap.values()));
  Set<PackageIdentifier> pkgIdsNeededForTargetification=packageKeyToTargetKeyMap.keySet().stream().map(SkyQueryEnvironment.PACKAGE_SKYKEY_TO_PACKAGE_IDENTIFIER).collect(toImmutableSet());
  packageSemaphore.acquireAll(pkgIdsNeededForTargetification);
  try {
    if (!reverseDepMultimap.isEmpty()) {
      Collection<Target> filteredTargets=env.filterRawReverseDepsOfTransitiveTraversalKeys(reverseDepMultimap.asMap(),packageKeyToTargetKeyMap);
      filteredTargets.stream().map(SkyQueryEnvironment.TARGET_TO_SKY_KEY).forEachOrdered(validRdeps::add);
    }
  }
  finally {
    packageSemaphore.releaseAll(pkgIdsNeededForTargetification);
  }
  ImmutableList.Builder<SkyKey> uniqueValidRdepsbuilder=ImmutableList.builder();
  for (  SkyKey rdep : validRdeps) {
    if (validRdepUniquifier.unique(rdep)) {
      uniqueValidRdepsbuilder.add(rdep);
    }
  }
  ImmutableList<SkyKey> uniqueValidRdeps=uniqueValidRdepsbuilder.build();
  ImmutableList.Builder<DepAndRdep> depAndRdepsToVisitBuilder=ImmutableList.builder();
  env.graph.getReverseDeps(uniqueValidRdeps).entrySet().forEach(reverseDepsEntry -> depAndRdepsToVisitBuilder.addAll(Iterables.transform(Iterables.filter(reverseDepsEntry.getValue(),Predicates.and(SkyQueryEnvironment.IS_TTV,unfilteredUniverse)),rdep -> new DepAndRdep(reverseDepsEntry.getKey(),rdep))));
  return new Visit(uniqueValidRdeps,depAndRdepsToVisitBuilder.build());
}