Program: 110658
Project: 110658
Buggy source:
@Override public Iterable<PathFragment> getPackagesUnderDirectory(ExtendedEventHandler eventHandler,RepositoryName repository,PathFragment directory,ImmutableSet<PathFragment> blacklistedSubdirectories,ImmutableSet<PathFragment> excludedSubdirectories) throws InterruptedException {
  PathFragment.checkAllPathsAreUnder(blacklistedSubdirectories,directory);
  PathFragment.checkAllPathsAreUnder(excludedSubdirectories,directory);
  if (excludedSubdirectories.contains(directory)) {
    return ImmutableList.of();
  }
  boolean inUniverse=false;
  for (  TargetPatternKey patternKey : universeTargetPatternKeys) {
    TargetPattern pattern=patternKey.getParsedPattern();
    boolean isTBD=pattern.getType().equals(Type.TARGETS_BELOW_DIRECTORY);
    PackageIdentifier packageIdentifier=PackageIdentifier.create(repository,directory);
    if (isTBD && pattern.containsAllTransitiveSubdirectoriesForTBD(packageIdentifier)) {
      inUniverse=true;
      break;
    }
  }
  if (!inUniverse) {
    return ImmutableList.of();
  }
  List<Path> roots=new ArrayList<>();
  if (repository.isMain()) {
    roots.addAll(pkgPath.getPathEntries());
  }
 else {
    RepositoryDirectoryValue repositoryValue=(RepositoryDirectoryValue)graph.getValue(RepositoryDirectoryValue.key(repository));
    if (repositoryValue == null || !repositoryValue.repositoryExists()) {
      return ImmutableList.of();
    }
    roots.add(repositoryValue.getPath());
  }
  ImmutableList.Builder<PathFragment> builder=ImmutableList.builder();
  for (  Path root : roots) {
    RootedPath rootedDir=RootedPath.toRootedPath(root,directory);
    TraversalInfo info=new TraversalInfo(rootedDir,blacklistedSubdirectories,excludedSubdirectories);
    collectPackagesUnder(eventHandler,repository,ImmutableSet.of(info),builder);
  }
  return builder.build();
}

Fixed version (ground truth):
@Override public Iterable<PathFragment> getPackagesUnderDirectory(ExtendedEventHandler eventHandler,RepositoryName repository,PathFragment directory,ImmutableSet<PathFragment> blacklistedSubdirectories,ImmutableSet<PathFragment> excludedSubdirectories) throws InterruptedException {
  if (blacklistedSubdirectories.contains(directory) || excludedSubdirectories.contains(directory)) {
    return ImmutableList.of();
  }
  PathFragment.checkAllPathsAreUnder(blacklistedSubdirectories,directory);
  PathFragment.checkAllPathsAreUnder(excludedSubdirectories,directory);
  boolean inUniverse=false;
  for (  TargetPatternKey patternKey : universeTargetPatternKeys) {
    TargetPattern pattern=patternKey.getParsedPattern();
    boolean isTBD=pattern.getType().equals(Type.TARGETS_BELOW_DIRECTORY);
    PackageIdentifier packageIdentifier=PackageIdentifier.create(repository,directory);
    if (isTBD && pattern.containsAllTransitiveSubdirectoriesForTBD(packageIdentifier)) {
      inUniverse=true;
      break;
    }
  }
  if (!inUniverse) {
    return ImmutableList.of();
  }
  List<Path> roots=new ArrayList<>();
  if (repository.isMain()) {
    roots.addAll(pkgPath.getPathEntries());
  }
 else {
    RepositoryDirectoryValue repositoryValue=(RepositoryDirectoryValue)graph.getValue(RepositoryDirectoryValue.key(repository));
    if (repositoryValue == null || !repositoryValue.repositoryExists()) {
      return ImmutableList.of();
    }
    roots.add(repositoryValue.getPath());
  }
  ImmutableList.Builder<PathFragment> builder=ImmutableList.builder();
  for (  Path root : roots) {
    RootedPath rootedDir=RootedPath.toRootedPath(root,directory);
    TraversalInfo info=new TraversalInfo(rootedDir,blacklistedSubdirectories,excludedSubdirectories);
    collectPackagesUnder(eventHandler,repository,ImmutableSet.of(info),builder);
  }
  return builder.build();
}