nus-yam/ex-repair huggingface dataset:
Program: 110612
Project: 110612
Buggy source:
@Test public void testCreatesManifestBasedRunfiles() throws Exception {
  try (MockFile mf=new MockFile(ImmutableList.of("String_Node_Str"))){
    Runfiles r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str",mf.path.toString(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
    assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
    assertThat(r.rlocation("String_Node_Str")).isNull();
  }
 }

Fixed version (ground truth):
@Test public void testCreatesManifestBasedRunfiles() throws Exception {
  try (MockFile mf=new MockFile(ImmutableList.of("String_Node_Str"))){
    Runfiles r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str",mf.path.toString(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
    assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
    assertThat(r.rlocation("String_Node_Str")).isNull();
    if (isWindows()) {
      assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
      assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
      assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
    }
 else {
      assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
    }
  }
 }
Program: 110613
Project: 110613
Buggy source:
@Test public void testCreatesDirectoryBasedRunfiles() throws Exception {
  Runfiles r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
  r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testCreatesDirectoryBasedRunfiles() throws Exception {
  Runfiles r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
  r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
  assertThat(r.rlocation("String_Node_Str")).isEqualTo("String_Node_Str");
}
Program: 110614
Project: 110614
Buggy source:
@Test public void testRlocationArgumentValidation() throws Exception {
  Runfiles r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str"));
  assertRlocationArg(r,null,null);
  assertRlocationArg(r,"String_Node_Str",null);
  assertRlocationArg(r,"String_Node_Str","String_Node_Str");
  if (File.separatorChar == '/') {
    assertRlocationArg(r,"String_Node_Str","String_Node_Str");
  }
 else {
    assertRlocationArg(r,"String_Node_Str","String_Node_Str");
    assertRlocationArg(r,"String_Node_Str","String_Node_Str");
    assertRlocationArg(r,"String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void testRlocationArgumentValidation() throws Exception {
  Runfiles r=Runfiles.create(ImmutableMap.of("String_Node_Str","String_Node_Str"));
  assertRlocationArg(r,null,null);
  assertRlocationArg(r,"String_Node_Str",null);
  assertRlocationArg(r,"String_Node_Str","String_Node_Str");
}
Program: 110615
Project: 110615
Buggy source:
static DirectTraversalRoot forFileOrDirectory(Artifact fileOrDirectory){
  return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(fileOrDirectory.getRoot().getRoot(),fileOrDirectory.getRootRelativePath());
}

Fixed version (ground truth):
public static DirectTraversalRoot forFileOrDirectory(Artifact fileOrDirectory){
  return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(fileOrDirectory.isSourceArtifact() ? null : fileOrDirectory,fileOrDirectory.getRoot().getRoot(),fileOrDirectory.getRootRelativePath());
}
Program: 110616
Project: 110616
Buggy source:
static DirectTraversalRoot forPackage(Artifact buildFile){
  return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(buildFile.getRoot().getRoot(),buildFile.getRootRelativePath().getParentDirectory());
}

Fixed version (ground truth):
public static DirectTraversalRoot forPackage(Artifact buildFile){
  return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(null,buildFile.getRoot().getRoot(),buildFile.getRootRelativePath().getParentDirectory());
}
Program: 110617
Project: 110617
Buggy source:
private static RecursiveFilesystemTraversalValue traverse(Environment env,String errorInfo,DirectTraversal traversal) throws MissingDepException, InterruptedException {
  SkyKey depKey=RecursiveFilesystemTraversalValue.key(new RecursiveFilesystemTraversalValue.TraversalRequest(traversal.getRoot().asRootedPath(),traversal.isGenerated(),traversal.getPackageBoundaryMode(),traversal.isPackage(),errorInfo));
  RecursiveFilesystemTraversalValue v=(RecursiveFilesystemTraversalValue)env.getValue(depKey);
  if (env.valuesMissing()) {
    throw new MissingDepException();
  }
  return v;
}

Fixed version (ground truth):
private static RecursiveFilesystemTraversalValue traverse(Environment env,String errorInfo,DirectTraversal traversal) throws MissingDepException, InterruptedException {
  SkyKey depKey=RecursiveFilesystemTraversalValue.key(new RecursiveFilesystemTraversalValue.TraversalRequest(traversal.getRoot(),traversal.isGenerated(),traversal.getPackageBoundaryMode(),traversal.isPackage(),errorInfo));
  RecursiveFilesystemTraversalValue v=(RecursiveFilesystemTraversalValue)env.getValue(depKey);
  if (env.valuesMissing()) {
    throw new MissingDepException();
  }
  return v;
}
Program: 110620
Project: 110620
Buggy source:
/** 
 * Checks whether the   {@code traversal}'s path refers to a package directory.
 * @return the result of the lookup; it contains potentially new {@link TraversalRequest} and{@link FileInfo} so the caller should use these instead of the old ones (this happens whena package is found, but under a different root than expected)
 */
private static PkgLookupResult checkIfPackage(Environment env,TraversalRequest traversal,FileInfo rootInfo) throws MissingDepException, IOException, InterruptedException {
  Preconditions.checkArgument(rootInfo.type.exists() && !rootInfo.type.isFile(),"String_Node_Str",traversal,rootInfo);
  PackageLookupValue pkgLookup=(PackageLookupValue)getDependentSkyValue(env,PackageLookupValue.key(traversal.path.getRootRelativePath()));
  if (pkgLookup.packageExists()) {
    if (traversal.isGenerated) {
      return PkgLookupResult.conflict(traversal,rootInfo);
    }
 else {
      Root pkgRoot=pkgLookup.getRoot();
      if (!pkgRoot.equals(traversal.path.getRoot())) {
        traversal=traversal.forChangedRootPath(pkgRoot);
        rootInfo=lookUpFileInfo(env,traversal);
        Verify.verify(rootInfo.type.exists(),"String_Node_Str",traversal,rootInfo);
      }
      return PkgLookupResult.pkg(traversal,rootInfo);
    }
  }
 else {
    return PkgLookupResult.directory(traversal,rootInfo);
  }
}

Fixed version (ground truth):
/** 
 * Checks whether the   {@code traversal}'s path refers to a package directory.
 * @return the result of the lookup; it contains potentially new {@link TraversalRequest} and{@link FileInfo} so the caller should use these instead of the old ones (this happens whena package is found, but under a different root than expected)
 */
private static PkgLookupResult checkIfPackage(Environment env,TraversalRequest traversal,FileInfo rootInfo) throws MissingDepException, IOException, InterruptedException {
  Preconditions.checkArgument(rootInfo.type.exists() && !rootInfo.type.isFile(),"String_Node_Str",traversal,rootInfo);
  PackageLookupValue pkgLookup=(PackageLookupValue)getDependentSkyValue(env,PackageLookupValue.key(traversal.root.asRootedPath().getRootRelativePath()));
  if (pkgLookup.packageExists()) {
    if (traversal.isGenerated) {
      return PkgLookupResult.conflict(traversal,rootInfo);
    }
 else {
      Root pkgRoot=pkgLookup.getRoot();
      if (!pkgRoot.equals(traversal.root.asRootedPath().getRoot())) {
        traversal=traversal.forChangedRootPath(pkgRoot);
        rootInfo=lookUpFileInfo(env,traversal);
        Verify.verify(rootInfo.type.exists(),"String_Node_Str",traversal,rootInfo);
      }
      return PkgLookupResult.pkg(traversal,rootInfo);
    }
  }
 else {
    return PkgLookupResult.directory(traversal,rootInfo);
  }
}
Program: 110621
Project: 110621
Buggy source:
GeneratedPathConflictException(TraversalRequest traversal){
  super(String.format("String_Node_Str" + "String_Node_Str",traversal.path.getRootRelativePath().getPathString(),traversal.errorInfo != null ? traversal.errorInfo : traversal.toString()));
}

Fixed version (ground truth):
GeneratedPathConflictException(TraversalRequest traversal){
  super(String.format("String_Node_Str" + "String_Node_Str",traversal.root.asRootedPath().getRootRelativePath().getPathString(),traversal.errorInfo != null ? traversal.errorInfo : traversal.toString()));
}
Program: 110622
Project: 110622
Buggy source:
/** 
 * List the directory and create   {@code SkyKey}s to request contents of its children recursively. <p>The returned keys are of type   {@link SkyFunctions#RECURSIVE_FILESYSTEM_TRAVERSAL}.
 */
private static Collection<SkyKey> createRecursiveTraversalKeys(Environment env,TraversalRequest traversal) throws MissingDepException, InterruptedException {
  DirectoryListingValue dirListing=(DirectoryListingValue)getDependentSkyValue(env,DirectoryListingValue.key(traversal.path));
  List<SkyKey> result=new ArrayList<>();
  for (  Dirent dirent : dirListing.getDirents()) {
    RootedPath childPath=RootedPath.toRootedPath(traversal.path.getRoot(),traversal.path.getRootRelativePath().getRelative(dirent.getName()));
    TraversalRequest childTraversal=traversal.forChildEntry(childPath);
    result.add(RecursiveFilesystemTraversalValue.key(childTraversal));
  }
  return result;
}

Fixed version (ground truth):
/** 
 * List the directory and create   {@code SkyKey}s to request contents of its children recursively. <p>The returned keys are of type   {@link SkyFunctions#RECURSIVE_FILESYSTEM_TRAVERSAL}.
 */
private static Collection<SkyKey> createRecursiveTraversalKeys(Environment env,TraversalRequest traversal) throws MissingDepException, InterruptedException, IOException {
  Iterable<Dirent> dirents;
  if (traversal.isGenerated) {
    List<Dirent> direntsCollection=new ArrayList<>(traversal.root.asRootedPath().asPath().readdir(Symlinks.FOLLOW));
    Collections.sort(direntsCollection);
    dirents=direntsCollection;
  }
 else {
    dirents=((DirectoryListingValue)getDependentSkyValue(env,DirectoryListingValue.key(traversal.root.asRootedPath()))).getDirents();
  }
  List<SkyKey> result=new ArrayList<>();
  for (  Dirent dirent : dirents) {
    RootedPath childPath=RootedPath.toRootedPath(traversal.root.asRootedPath().getRoot(),traversal.root.asRootedPath().getRootRelativePath().getRelative(dirent.getName()));
    TraversalRequest childTraversal=traversal.forChildEntry(childPath);
    result.add(RecursiveFilesystemTraversalValue.key(childTraversal));
  }
  return result;
}
Program: 110623
Project: 110623
Buggy source:
private static RecursiveFilesystemTraversalValue resultForDirectory(TraversalRequest traversal,FileInfo rootInfo,Collection<RecursiveFilesystemTraversalValue> subdirTraversals){
  NestedSetBuilder<ResolvedFile> paths=NestedSetBuilder.stableOrder();
  for (  RecursiveFilesystemTraversalValue child : subdirTraversals) {
    paths.addTransitive(child.getTransitiveFiles());
  }
  ResolvedFile root;
  if (rootInfo.type.isSymlink()) {
    NestedSet<ResolvedFile> children=paths.build();
    root=ResolvedFileFactory.symlinkToDirectory(rootInfo.realPath,traversal.path,rootInfo.unresolvedSymlinkTarget,hashDirectorySymlink(children,rootInfo.metadata.hashCode()));
    paths=NestedSetBuilder.<ResolvedFile>stableOrder().addTransitive(children).add(root);
  }
 else {
    root=ResolvedFileFactory.directory(rootInfo.realPath);
  }
  return RecursiveFilesystemTraversalValue.of(root,paths.build());
}

Fixed version (ground truth):
private static RecursiveFilesystemTraversalValue resultForDirectory(TraversalRequest traversal,FileInfo rootInfo,Collection<RecursiveFilesystemTraversalValue> subdirTraversals){
  NestedSetBuilder<ResolvedFile> paths=NestedSetBuilder.stableOrder();
  for (  RecursiveFilesystemTraversalValue child : subdirTraversals) {
    paths.addTransitive(child.getTransitiveFiles());
  }
  ResolvedFile root;
  if (rootInfo.type.isSymlink()) {
    NestedSet<ResolvedFile> children=paths.build();
    root=ResolvedFileFactory.symlinkToDirectory(rootInfo.realPath,traversal.root.asRootedPath(),rootInfo.unresolvedSymlinkTarget,hashDirectorySymlink(children,rootInfo.metadata.hashCode()));
    paths=NestedSetBuilder.<ResolvedFile>stableOrder().addTransitive(children).add(root);
  }
 else {
    root=ResolvedFileFactory.directory(rootInfo.realPath);
  }
  return RecursiveFilesystemTraversalValue.of(root,paths.build());
}
Program: 110624
Project: 110624
Buggy source:
boolean isFile(){
  return false;
}

Fixed version (ground truth):
@Override public boolean isFile(){
  return noFollowStat.isFile();
}
Program: 110625
Project: 110625
Buggy source:
/** 
 * Requests Skyframe to compute the dependent values and returns them. <p>The keys must all be   {@link SkyFunctions#RECURSIVE_FILESYSTEM_TRAVERSAL} keys.
 */
private static Collection<RecursiveFilesystemTraversalValue> traverseChildren(Environment env,Iterable<SkyKey> keys) throws MissingDepException, InterruptedException {
  Map<SkyKey,SkyValue> values=env.getValues(keys);
  if (env.valuesMissing()) {
    throw new MissingDepException();
  }
  return Collections2.transform(values.values(),new Function<SkyValue,RecursiveFilesystemTraversalValue>(){
    @Override public RecursiveFilesystemTraversalValue apply(    SkyValue input){
      return (RecursiveFilesystemTraversalValue)input;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Requests Skyframe to compute the dependent values and returns them. <p>The keys must all be   {@link SkyFunctions#RECURSIVE_FILESYSTEM_TRAVERSAL} keys.
 */
private Collection<RecursiveFilesystemTraversalValue> traverseChildren(Environment env,Iterable<SkyKey> keys,boolean inline) throws MissingDepException, InterruptedException, RecursiveFilesystemTraversalFunctionException {
  Map<SkyKey,SkyValue> values;
  if (inline) {
    values=new HashMap<>();
    for (    SkyKey depKey : keys) {
      values.put(depKey,compute(depKey,env));
    }
  }
 else {
    values=env.getValues(keys);
  }
  if (env.valuesMissing()) {
    throw new MissingDepException();
  }
  return Collections2.transform(values.values(),new Function<SkyValue,RecursiveFilesystemTraversalValue>(){
    @Override public RecursiveFilesystemTraversalValue apply(    SkyValue input){
      return (RecursiveFilesystemTraversalValue)input;
    }
  }
);
}
Program: 110626
Project: 110626
Buggy source:
boolean isDirectory(){
  return false;
}

Fixed version (ground truth):
@Override public boolean isDirectory(){
  return noFollowStat.isDirectory();
}
Program: 110629
Project: 110629
Buggy source:
/** 
 * Creates a new   {@link ImmutableListSerializer} and registers its serializer for the severalImmutableList related classes.
 * @param kryo the {@link Kryo} instance to set the serializer on
 */
static void registerSerializers(Kryo kryo){
  ImmutableListSerializer serializer=new ImmutableListSerializer();
  kryo.register(ImmutableList.class,serializer);
  kryo.register(ImmutableList.of().getClass(),serializer);
  kryo.register(ImmutableList.of(1).getClass(),serializer);
  kryo.register(ImmutableList.of(1,2,3,4).subList(1,3).getClass(),serializer);
  kryo.register(ImmutableList.of(1,2).reverse().getClass(),serializer);
  kryo.register(Lists.charactersOf("String_Node_Str").getClass(),serializer);
  Table<Integer,Integer,Integer> baseTable=HashBasedTable.create();
  baseTable.put(1,2,3);
  baseTable.put(4,5,6);
  Table<Integer,Integer,Integer> table=ImmutableTable.copyOf(baseTable);
  kryo.register(table.values().getClass(),serializer);
}

Fixed version (ground truth):
/** 
 * Creates a new   {@link ImmutableListSerializer} and registers its serializer for the severalImmutableList related classes.
 * @param kryo the {@link Kryo} instance to set the serializer on
 */
static void registerSerializers(Kryo kryo){
  ImmutableListSerializer serializer=new ImmutableListSerializer();
  kryo.register(ImmutableList.class,serializer);
  kryo.register(ImmutableList.of().getClass(),serializer);
  kryo.register(ImmutableList.of(1).getClass(),serializer);
  kryo.register(ImmutableList.of(1,2).getClass(),serializer);
  kryo.register(ImmutableList.of(1,2,3,4).subList(1,3).getClass(),serializer);
  kryo.register(ImmutableList.of(1,2).reverse().getClass(),serializer);
  kryo.register(Lists.charactersOf("String_Node_Str").getClass(),serializer);
  Table<Integer,Integer,Integer> baseTable=HashBasedTable.create();
  baseTable.put(1,2,3);
  baseTable.put(4,5,6);
  Table<Integer,Integer,Integer> table=ImmutableTable.copyOf(baseTable);
  kryo.register(table.values().getClass(),serializer);
}
Program: 110630
Project: 110630
Buggy source:
@Override public ImmutableMultimap<Object,Object> read(Kryo kryo,Input input,Class<ImmutableMultimap<Object,Object>> type){
  ImmutableMultimap.Builder<Object,Object> builder;
  if (type.equals(ImmutableListMultimap.class)) {
    builder=ImmutableMultimap.builder();
  }
 else   if (type.equals(ImmutableSetMultimap.class)) {
    builder=ImmutableSetMultimap.builder();
  }
 else {
    builder=ImmutableMultimap.builder();
  }
  @SuppressWarnings("String_Node_Str") Map<Object,Collection<Object>> map=kryo.readObject(input,ImmutableMap.class);
  for (  Map.Entry<Object,Collection<Object>> entry : map.entrySet()) {
    builder.putAll(entry.getKey(),entry.getValue());
  }
  return builder.build();
}

Fixed version (ground truth):
@Override public ImmutableMultimap<Object,Object> read(Kryo kryo,Input input,Class<ImmutableMultimap<Object,Object>> type){
  ImmutableMultimap.Builder<Object,Object> builder;
  if (type.equals(ImmutableListMultimap.class)) {
    builder=ImmutableListMultimap.builder();
  }
 else   if (type.equals(ImmutableSetMultimap.class)) {
    builder=ImmutableSetMultimap.builder();
  }
 else {
    builder=ImmutableMultimap.builder();
  }
  @SuppressWarnings("String_Node_Str") Map<Object,Collection<Object>> map=kryo.readObject(input,ImmutableMap.class);
  for (  Map.Entry<Object,Collection<Object>> entry : map.entrySet()) {
    builder.putAll(entry.getKey(),entry.getValue());
  }
  return builder.build();
}
Program: 110631
Project: 110631
Buggy source:
/** 
 * Registers Serializers defined in this package. 
 */
private static void registerSerializers(Kryo kryo){
  kryo.register(Ordering.natural().getClass());
  kryo.register(Collections.reverseOrder().getClass());
  HashCodeSerializer.registerSerializers(kryo);
  ImmutableListSerializer.registerSerializers(kryo);
  ImmutableMapSerializer.registerSerializers(kryo);
  ImmutableMultimapSerializer.registerSerializers(kryo);
  ImmutableSetSerializer.registerSerializers(kryo);
  ImmutableSortedSetSerializer.registerSerializers(kryo);
  MapEntrySerializer.registerSerializers(kryo);
  MultimapSerializer.registerSerializers(kryo);
  PatternSerializer.registerSerializers(kryo);
  ReverseListSerializer.registerSerializers(kryo);
  OptionalSerializer.registerSerializers(kryo);
  UnmodifiableNavigableSetSerializer.registerSerializers(kryo);
}

Fixed version (ground truth):
/** 
 * Registers Serializers defined in this package. 
 */
private static void registerSerializers(Kryo kryo){
  kryo.register(Ordering.natural().getClass());
  kryo.register(Collections.reverseOrder().getClass());
  ClassSerializer.registerSerializers(kryo);
  HashCodeSerializer.registerSerializers(kryo);
  ImmutableListSerializer.registerSerializers(kryo);
  ImmutableMapSerializer.registerSerializers(kryo);
  ImmutableMultimapSerializer.registerSerializers(kryo);
  ImmutableSetSerializer.registerSerializers(kryo);
  ImmutableSortedMapSerializer.registerSerializers(kryo);
  ImmutableSortedSetSerializer.registerSerializers(kryo);
  MapEntrySerializer.registerSerializers(kryo);
  MultimapSerializer.registerSerializers(kryo);
  PatternSerializer.registerSerializers(kryo);
  ReverseListSerializer.registerSerializers(kryo);
  OptionalSerializer.registerSerializers(kryo);
  UnmodifiableListSerializer.registerSerializers(kryo);
  UnmodifiableMapSerializer.registerSerializers(kryo);
  UnmodifiableNavigableSetSerializer.registerSerializers(kryo);
}
Program: 110632
Project: 110632
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public T read(Kryo kryo,Input input,Class<T> unusedType){
  T multimap=create.get();
  int size=input.readInt(true);
  for (int i=0; i < size; ++i) {
    multimap.put((E)kryo.readClassAndObject(input),(E)kryo.readClassAndObject(input));
  }
  return multimap;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public T read(Kryo kryo,Input input,Class<T> unusedType){
  T multimap=create.get();
  kryo.reference(multimap);
  int size=input.readInt(true);
  for (int i=0; i < size; ++i) {
    multimap.put((E)kryo.readClassAndObject(input),(E)kryo.readClassAndObject(input));
  }
  return multimap;
}
Program: 110634
Project: 110634
Buggy source:
@Test public void errorTransienceBug() throws Exception {
  tester.getOrCreate("String_Node_Str").setHasTransientError(true);
  assertThat(tester.evalAndGetError("String_Node_Str").getException()).isNotNull();
  StringValue value=new StringValue("String_Node_Str");
  tester.getOrCreate("String_Node_Str").setHasTransientError(false).setConstantValue(value);
  tester.invalidateTransientErrors();
  assertThat(tester.evalAndGet("String_Node_Str")).isEqualTo(value);
}

Fixed version (ground truth):
@Test public void errorTransienceBug() throws Exception {
  tester.getOrCreate("String_Node_Str").setHasTransientError(true);
  assertThat(tester.evalAndGetError(true,"String_Node_Str").getException()).isNotNull();
  StringValue value=new StringValue("String_Node_Str");
  tester.getOrCreate("String_Node_Str").setHasTransientError(false).setConstantValue(value);
  tester.invalidateTransientErrors();
  assertThat(tester.evalAndGet("String_Node_Str")).isEqualTo(value);
}
Program: 110635
Project: 110635
Buggy source:
protected void runTestPersistentErrorsNotRerun(boolean includeTransientError) throws Exception {
  SkyKey topKey=GraphTester.toSkyKey("String_Node_Str");
  SkyKey transientErrorKey=GraphTester.toSkyKey("String_Node_Str");
  SkyKey persistentErrorKey1=GraphTester.toSkyKey("String_Node_Str");
  SkyKey persistentErrorKey2=GraphTester.toSkyKey("String_Node_Str");
  TestFunction topFunction=tester.getOrCreate(topKey).addErrorDependency(persistentErrorKey1,new StringValue("String_Node_Str")).setHasError(true);
  tester.getOrCreate(persistentErrorKey1).setHasError(true);
  if (includeTransientError) {
    topFunction.addErrorDependency(transientErrorKey,new StringValue("String_Node_Str"));
    tester.getOrCreate(transientErrorKey).addErrorDependency(persistentErrorKey2,new StringValue("String_Node_Str")).setHasTransientError(true);
  }
  tester.getOrCreate(persistentErrorKey2).setHasError(true);
  tester.evalAndGetError(topKey);
  if (includeTransientError) {
    assertThat(tester.getEnqueuedValues()).containsExactly(topKey,transientErrorKey,persistentErrorKey1,persistentErrorKey2);
  }
 else {
    assertThat(tester.getEnqueuedValues()).containsExactly(topKey,persistentErrorKey1);
  }
  tester.invalidate();
  tester.invalidateTransientErrors();
  tester.evalAndGetError(topKey);
  if (includeTransientError) {
    assertThat(tester.getEnqueuedValues()).containsExactly(topKey,transientErrorKey);
  }
 else {
    assertThat(tester.getEnqueuedValues()).isEmpty();
  }
}

Fixed version (ground truth):
protected void runTestPersistentErrorsNotRerun(boolean includeTransientError) throws Exception {
  SkyKey topKey=GraphTester.toSkyKey("String_Node_Str");
  SkyKey transientErrorKey=GraphTester.toSkyKey("String_Node_Str");
  SkyKey persistentErrorKey1=GraphTester.toSkyKey("String_Node_Str");
  SkyKey persistentErrorKey2=GraphTester.toSkyKey("String_Node_Str");
  TestFunction topFunction=tester.getOrCreate(topKey).addErrorDependency(persistentErrorKey1,new StringValue("String_Node_Str")).setHasError(true);
  tester.getOrCreate(persistentErrorKey1).setHasError(true);
  if (includeTransientError) {
    topFunction.addErrorDependency(transientErrorKey,new StringValue("String_Node_Str"));
    tester.getOrCreate(transientErrorKey).addErrorDependency(persistentErrorKey2,new StringValue("String_Node_Str")).setHasTransientError(true);
  }
  tester.getOrCreate(persistentErrorKey2).setHasError(true);
  tester.evalAndGetError(true,topKey);
  if (includeTransientError) {
    assertThat(tester.getEnqueuedValues()).containsExactly(topKey,transientErrorKey,persistentErrorKey1,persistentErrorKey2);
  }
 else {
    assertThat(tester.getEnqueuedValues()).containsExactly(topKey,persistentErrorKey1);
  }
  tester.invalidate();
  tester.invalidateTransientErrors();
  tester.evalAndGetError(true,topKey);
  if (includeTransientError) {
    assertThat(tester.getEnqueuedValues()).containsExactly(topKey,transientErrorKey);
  }
 else {
    assertThat(tester.getEnqueuedValues()).isEmpty();
  }
}
Program: 110636
Project: 110636
Buggy source:
/** 
 * Regression test for 2014 bug: error transience value is registered before newly requested deps. A value requests a child, gets it back immediately, and then throws, causing the error transience value to be registered as a dep. The following build, the error is invalidated via that child.
 */
@Test public void doubleDepOnErrorTransienceValue() throws Exception {
  initializeTester();
  SkyKey leafKey=GraphTester.toSkyKey("String_Node_Str");
  tester.set(leafKey,new StringValue("String_Node_Str"));
  assertThat(tester.evalAndGet(false,leafKey)).isEqualTo(new StringValue("String_Node_Str"));
  SkyKey topKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(topKey).addDependency(leafKey).setHasError(true);
  assertThat(tester.evalAndGetError(topKey).getRootCauses()).containsExactly(topKey).inOrder();
  tester.set(leafKey,new StringValue("String_Node_Str"));
  tester.invalidate();
  assertThat(tester.evalAndGetError(topKey).getRootCauses()).containsExactly(topKey).inOrder();
}

Fixed version (ground truth):
/** 
 * Regression test for 2014 bug: error transience value is registered before newly requested deps. A value requests a child, gets it back immediately, and then throws, causing the error transience value to be registered as a dep. The following build, the error is invalidated via that child.
 */
@Test public void doubleDepOnErrorTransienceValue() throws Exception {
  initializeTester();
  SkyKey leafKey=GraphTester.toSkyKey("String_Node_Str");
  tester.set(leafKey,new StringValue("String_Node_Str"));
  assertThat(tester.evalAndGet(false,leafKey)).isEqualTo(new StringValue("String_Node_Str"));
  SkyKey topKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(topKey).addDependency(leafKey).setHasError(true);
  assertThat(tester.evalAndGetError(true,topKey).getRootCauses()).containsExactly(topKey).inOrder();
  tester.set(leafKey,new StringValue("String_Node_Str"));
  tester.invalidate();
  assertThat(tester.evalAndGetError(true,topKey).getRootCauses()).containsExactly(topKey).inOrder();
}
Program: 110637
Project: 110637
Buggy source:
@Test public void errorValueDepOnWarningValue() throws Exception {
  tester.getOrCreate("String_Node_Str").setHasError(true).addDependency("String_Node_Str");
  tester.set("String_Node_Str",new StringValue("String_Node_Str")).setWarning("String_Node_Str");
  for (int i=0; i < 2; i++) {
    initializeReporter();
    tester.evalAndGetError("String_Node_Str");
    if (i == 0 || eventsStored()) {
      assertThatEvents(eventCollector).containsExactly("String_Node_Str");
    }
  }
  initializeReporter();
  tester.evalAndGet("String_Node_Str");
  if (eventsStored()) {
    assertThatEvents(eventCollector).containsExactly("String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void errorValueDepOnWarningValue() throws Exception {
  tester.getOrCreate("String_Node_Str").setHasError(true).addDependency("String_Node_Str");
  tester.set("String_Node_Str",new StringValue("String_Node_Str")).setWarning("String_Node_Str");
  for (int i=0; i < 2; i++) {
    initializeReporter();
    tester.evalAndGetError(true,"String_Node_Str");
    if (i == 0 || eventsStored()) {
      assertThatEvents(eventCollector).containsExactly("String_Node_Str");
    }
  }
  initializeReporter();
  tester.evalAndGet("String_Node_Str");
  if (eventsStored()) {
    assertThatEvents(eventCollector).containsExactly("String_Node_Str");
  }
}
Program: 110638
Project: 110638
Buggy source:
@Test public void errorChanged() throws Exception {
  SkyKey error=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(error).setHasError(true);
  assertThatErrorInfo(tester.evalAndGetError(error)).hasExceptionThat().isNotNull();
  tester.getOrCreate(error,true);
  tester.invalidate();
  assertThatErrorInfo(tester.evalAndGetError(error)).hasExceptionThat().isNotNull();
}

Fixed version (ground truth):
@Test public void errorChanged() throws Exception {
  SkyKey error=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(error).setHasError(true);
  assertThatErrorInfo(tester.evalAndGetError(true,error)).hasExceptionThat().isNotNull();
  tester.getOrCreate(error,true);
  tester.invalidate();
  assertThatErrorInfo(tester.evalAndGetError(true,error)).hasExceptionThat().isNotNull();
}
Program: 110639
Project: 110639
Buggy source:
@Test public void errorDepAlreadyThereThenTurnedGood() throws Exception {
  initializeTester();
  SkyKey errorKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(errorKey).setHasError(true);
  SkyKey parentKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(parentKey).addErrorDependency(errorKey,new StringValue("String_Node_Str")).setHasError(true);
  assertThat(tester.evalAndGetError(errorKey).getRootCauses()).containsExactly(errorKey);
  EvaluationResult<StringValue> result=tester.eval(false,parentKey);
  assertThat(result.getError(parentKey).getRootCauses()).containsExactly(parentKey).inOrder();
  tester.set(errorKey,new StringValue("String_Node_Str")).setHasError(false);
  tester.getOrCreate(parentKey,false).setHasError(false).setComputedValue(COPY);
  tester.differencer.invalidate(ImmutableList.of(errorKey));
  tester.invalidate();
  result=tester.eval(false,parentKey);
  assertThat(result.errorMap()).isEmpty();
  assertThat(result.get(parentKey).getValue()).isEqualTo("String_Node_Str");
  tester.getOrCreate(parentKey,false).setHasError(true);
  tester.invalidateTransientErrors();
  result=tester.eval(false,parentKey);
  assertThat(result.errorMap()).isEmpty();
  assertThat(result.get(parentKey).getValue()).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void errorDepAlreadyThereThenTurnedGood() throws Exception {
  initializeTester();
  SkyKey errorKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(errorKey).setHasError(true);
  SkyKey parentKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(parentKey).addErrorDependency(errorKey,new StringValue("String_Node_Str")).setHasError(true);
  assertThat(tester.evalAndGetError(true,errorKey).getRootCauses()).containsExactly(errorKey);
  EvaluationResult<StringValue> result=tester.eval(false,parentKey);
  assertThat(result.getError(parentKey).getRootCauses()).containsExactly(parentKey).inOrder();
  tester.set(errorKey,new StringValue("String_Node_Str")).setHasError(false);
  tester.getOrCreate(parentKey,false).setHasError(false).setComputedValue(COPY);
  tester.differencer.invalidate(ImmutableList.of(errorKey));
  tester.invalidate();
  result=tester.eval(false,parentKey);
  assertThat(result.errorMap()).isEmpty();
  assertThat(result.get(parentKey).getValue()).isEqualTo("String_Node_Str");
  tester.getOrCreate(parentKey,false).setHasError(true);
  tester.invalidateTransientErrors();
  result=tester.eval(false,parentKey);
  assertThat(result.errorMap()).isEmpty();
  assertThat(result.get(parentKey).getValue()).isEqualTo("String_Node_Str");
}
Program: 110640
Project: 110640
Buggy source:
@Test public void transientErrorTurningGoodHasNoError() throws Exception {
  initializeTester();
  SkyKey errorKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(errorKey).setHasTransientError(true);
  ErrorInfo errorInfo=tester.evalAndGetError(errorKey);
  assertThat(errorInfo).isNotNull();
  assertThat(errorInfo.getRootCauses()).containsExactly(errorKey);
  tester.invalidateTransientErrors();
  errorInfo=tester.evalAndGetError(errorKey);
  assertThat(errorInfo).isNotNull();
  StringValue value=new StringValue("String_Node_Str");
  assertThat(errorInfo.getRootCauses()).containsExactly(errorKey);
  tester.getOrCreate(errorKey,false).setHasTransientError(false).setConstantValue(value);
  tester.invalidateTransientErrors();
  StringValue stringValue=(StringValue)tester.evalAndGet(true,errorKey);
  assertThat(value).isSameAs(stringValue);
  tester.getOrCreate(errorKey,false).setHasTransientError(true);
  tester.invalidateTransientErrors();
  stringValue=(StringValue)tester.evalAndGet(true,errorKey);
  assertThat(stringValue).isEqualTo(value);
}

Fixed version (ground truth):
@Test public void transientErrorTurningGoodHasNoError() throws Exception {
  initializeTester();
  SkyKey errorKey=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(errorKey).setHasTransientError(true);
  ErrorInfo errorInfo=tester.evalAndGetError(true,errorKey);
  assertThat(errorInfo).isNotNull();
  assertThat(errorInfo.getRootCauses()).containsExactly(errorKey);
  tester.invalidateTransientErrors();
  errorInfo=tester.evalAndGetError(true,errorKey);
  assertThat(errorInfo).isNotNull();
  StringValue value=new StringValue("String_Node_Str");
  assertThat(errorInfo.getRootCauses()).containsExactly(errorKey);
  tester.getOrCreate(errorKey,false).setHasTransientError(false).setConstantValue(value);
  tester.invalidateTransientErrors();
  StringValue stringValue=(StringValue)tester.evalAndGet(true,errorKey);
  assertThat(value).isSameAs(stringValue);
  tester.getOrCreate(errorKey,false).setHasTransientError(true);
  tester.invalidateTransientErrors();
  stringValue=(StringValue)tester.evalAndGet(true,errorKey);
  assertThat(stringValue).isEqualTo(value);
}
Program: 110641
Project: 110641
Buggy source:
@Override public SkyValue compute(Map<SkyKey,SkyValue> deps,SkyFunction.Environment env){
  return Preconditions.checkNotNull(deps.get(key));
}

Fixed version (ground truth):
@Nullable @Override public SkyValue compute(SkyKey skyKey,Environment env) throws SkyFunctionException, InterruptedException {
  numParentComputeCalls.incrementAndGet();
  if (!keepGoing || numParentComputeCalls.get() == 1) {
    Preconditions.checkState(env.getValue(childKey) == null);
    Preconditions.checkState(env.getValue(childKey) == null);
  }
 else {
    Preconditions.checkState(env.getValue(childKey).equals(childValue));
    Preconditions.checkState(env.getValue(childKey).equals(childValue));
  }
  throw new GenericFunctionException(parentExn,Transience.PERSISTENT);
}
Program: 110642
Project: 110642
Buggy source:
@Override public String extractTag(SkyKey skyKey){
  return null;
}

Fixed version (ground truth):
@Nullable @Override public String extractTag(SkyKey skyKey){
  return null;
}
Program: 110643
Project: 110643
Buggy source:
@Test public void transientPruning() throws Exception {
  SkyKey leaf=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate("String_Node_Str").setHasTransientError(true).addDependency(leaf);
  tester.set(leaf,new StringValue("String_Node_Str"));
  tester.evalAndGetError("String_Node_Str");
  tester.getOrCreate(leaf,true);
  tester.invalidate();
  tester.evalAndGetError("String_Node_Str");
}

Fixed version (ground truth):
@Test public void transientPruning() throws Exception {
  SkyKey leaf=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate("String_Node_Str").setHasTransientError(true).addDependency(leaf);
  tester.set(leaf,new StringValue("String_Node_Str"));
  tester.evalAndGetError(true,"String_Node_Str");
  tester.getOrCreate(leaf,true);
  tester.invalidate();
  tester.evalAndGetError(true,"String_Node_Str");
}
Program: 110644
Project: 110644
Buggy source:
@Test public void dirtyErrorTransienceValue() throws Exception {
  initializeTester();
  SkyKey error=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(error).setHasError(true);
  assertThat(tester.evalAndGetError(error)).isNotNull();
  tester.invalidateTransientErrors();
  SkyKey secondError=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(secondError).setHasError(true);
  assertThat(tester.evalAndGetError(secondError)).isNotNull();
}

Fixed version (ground truth):
@Test public void dirtyErrorTransienceValue() throws Exception {
  initializeTester();
  SkyKey error=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(error).setHasError(true);
  assertThat(tester.evalAndGetError(true,error)).isNotNull();
  tester.invalidateTransientErrors();
  SkyKey secondError=GraphTester.toSkyKey("String_Node_Str");
  tester.getOrCreate(secondError).setHasError(true);
  assertThat(tester.evalAndGetError(true,secondError)).isNotNull();
}
Program: 110645
Project: 110645
Buggy source:
@Test public void valueInjectionOverValueWithErrors() throws Exception {
  SkyKey key=GraphTester.toSkyKey("String_Node_Str");
  SkyValue val=new StringValue("String_Node_Str");
  tester.getOrCreate(key).setHasError(true);
  tester.evalAndGetError(key);
  tester.differencer.inject(ImmutableMap.of(key,val));
  assertThat(tester.evalAndGet(false,key)).isEqualTo(val);
}

Fixed version (ground truth):
@Test public void valueInjectionOverValueWithErrors() throws Exception {
  SkyKey key=GraphTester.toSkyKey("String_Node_Str");
  SkyValue val=new StringValue("String_Node_Str");
  tester.getOrCreate(key).setHasError(true);
  tester.evalAndGetError(true,key);
  tester.differencer.inject(ImmutableMap.of(key,val));
  assertThat(tester.evalAndGet(false,key)).isEqualTo(val);
}
Program: 110646
Project: 110646
Buggy source:
@Test public void cachedErrorShutsDownThreadpool() throws Exception {
  SkyKey cachedErrorKey=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(cachedErrorKey).setHasError(true);
  assertThat(tester.evalAndGetError(cachedErrorKey)).isNotNull();
  SkyKey topKey=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(topKey).addDependency(cachedErrorKey).setComputedValue(CONCATENATE);
  SkyKey newErrorKey=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(newErrorKey).setBuilder(new ChainedFunction.Builder().setWaitForException(true).setWaitToFinish(new CountDownLatch(0)).setValue(null).build());
  EvaluationResult<StringValue> result=tester.eval(false,newErrorKey,topKey);
  assertThatEvaluationResult(result).hasError();
  assertThatEvaluationResult(result).hasErrorEntryForKeyThat(newErrorKey).isNull();
}

Fixed version (ground truth):
@Test public void cachedErrorShutsDownThreadpool() throws Exception {
  SkyKey cachedErrorKey=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(cachedErrorKey).setHasError(true);
  assertThat(tester.evalAndGetError(true,cachedErrorKey)).isNotNull();
  SkyKey topKey=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(topKey).addDependency(cachedErrorKey).setComputedValue(CONCATENATE);
  SkyKey newErrorKey=GraphTester.skyKey("String_Node_Str");
  tester.getOrCreate(newErrorKey).setBuilder(new ChainedFunction.Builder().setWaitForException(true).setWaitToFinish(new CountDownLatch(0)).setValue(null).build());
  EvaluationResult<StringValue> result=tester.eval(false,newErrorKey,topKey);
  assertThatEvaluationResult(result).hasError();
  assertThatEvaluationResult(result).hasErrorEntryForKeyThat(newErrorKey).isNull();
}
Program: 110647
Project: 110647
Buggy source:
@Test public void transientErrorValueInvalidation() throws Exception {
  tester.getOrCreate("String_Node_Str").setHasTransientError(true).setProgress("String_Node_Str");
  tester.evalAndGetError("String_Node_Str");
  assertThatEvents(eventCollector).containsExactly("String_Node_Str");
  tester.getOrCreate("String_Node_Str").setHasTransientError(true).setProgress("String_Node_Str");
  for (int i=0; i < 2; i++) {
    initializeReporter();
    tester.evalAndGetError("String_Node_Str");
    assertThatEvents(eventCollector).isEmpty();
  }
  initializeReporter();
  tester.invalidateTransientErrors();
  tester.evalAndGetError("String_Node_Str");
  assertThatEvents(eventCollector).containsExactly("String_Node_Str");
}

Fixed version (ground truth):
@Test public void transientErrorValueInvalidation() throws Exception {
  tester.getOrCreate("String_Node_Str").setHasTransientError(true).setProgress("String_Node_Str");
  tester.evalAndGetError(true,"String_Node_Str");
  assertThatEvents(eventCollector).containsExactly("String_Node_Str");
  tester.getOrCreate("String_Node_Str").setHasTransientError(true).setProgress("String_Node_Str");
  for (int i=0; i < 2; i++) {
    initializeReporter();
    tester.evalAndGetError(true,"String_Node_Str");
    assertThatEvents(eventCollector).isEmpty();
  }
  initializeReporter();
  tester.invalidateTransientErrors();
  tester.evalAndGetError(true,"String_Node_Str");
  assertThatEvents(eventCollector).containsExactly("String_Node_Str");
}
Program: 110648
Project: 110648
Buggy source:
public ErrorInfo evalAndGetError(String key) throws InterruptedException {
  return evalAndGetError(toSkyKey(key));
}

Fixed version (ground truth):
public ErrorInfo evalAndGetError(boolean keepGoing,String key) throws InterruptedException {
  return evalAndGetError(keepGoing,toSkyKey(key));
}
Program: 110649
Project: 110649
Buggy source:
private ImmutableList<Path> findUnprocessed(String pathPrefix) throws IOException {
  Path rootPathPrefix=rootDirectory.resolve(pathPrefix);
  final String rootPathPrefixStr=rootPathPrefix.toString();
  if (!Files.exists(rootPathPrefix.getParent())) {
    return ImmutableList.of();
  }
  try (Stream<Path> paths=Files.list(rootPathPrefix.getParent()).filter(path -> path.toString().startsWith(rootPathPrefixStr) && !existingPaths.contains(path))){
    return paths.collect(ImmutableList.toImmutableList());
  }
 }

Fixed version (ground truth):
private ImmutableList<Path> findUnprocessed(String pathPrefix) throws IOException {
  Path rootPathPrefix=rootDirectory.resolve(pathPrefix);
  final String rootPathPrefixStr=rootPathPrefix.toString();
  if (!Files.exists(rootPathPrefix.getParent())) {
    return ImmutableList.of();
  }
  try (Stream<Path> paths=Files.list(rootPathPrefix.getParent())){
    return paths.filter(path -> path.toString().startsWith(rootPathPrefixStr) && !existingPaths.contains(path)).collect(ImmutableList.toImmutableList());
  }
 }
Program: 110651
Project: 110651
Buggy source:
/** 
 * Specialized parallel variant of   {@link SkyQueryEnvironment#getRBuildFiles}. 
 */
static void getRBuildFilesParallel(SkyQueryEnvironment env,Collection<PathFragment> fileIdentifiers,Callback<Target> callback) throws QueryException, InterruptedException {
  Uniquifier<SkyKey> keyUniquifier=env.createSkyKeyUniquifier();
  RBuildFilesVisitor visitor=new RBuildFilesVisitor(env,keyUniquifier,callback);
  visitor.visitAndWaitForCompletion(env.getSkyKeysForFileFragments(fileIdentifiers));
}

Fixed version (ground truth):
/** 
 * Specialized parallel variant of   {@link SkyQueryEnvironment#getRBuildFiles}. 
 */
static void getRBuildFilesParallel(SkyQueryEnvironment env,Collection<PathFragment> fileIdentifiers,Callback<Target> callback) throws QueryException, InterruptedException {
  Uniquifier<SkyKey> keyUniquifier=env.createSkyKeyUniquifier();
  RBuildFilesVisitor visitor=new RBuildFilesVisitor(env,keyUniquifier,callback);
  visitor.visitAndWaitForCompletion(env.getFileStateKeysForFileFragments(fileIdentifiers));
}
Program: 110653
Project: 110653
Buggy source:
/** 
 * Returns package lookup keys for looking up the package root for which there may be a relevant (from the perspective of   {@link #getRBuildFiles})   {@link FileValue} node in the graph for{@code originalFileFragment}, which is assumed to be a file path. <p>This is a helper function for   {@link #getSkyKeysForFileFragments}.
 */
private static Iterable<SkyKey> getPkgLookupKeysForFile(PathFragment originalFileFragment,PathFragment currentPathFragment){
  if (originalFileFragment.equals(currentPathFragment) && originalFileFragment.equals(Label.WORKSPACE_FILE_NAME)) {
    Preconditions.checkState(Label.WORKSPACE_FILE_NAME.getParentDirectory().equals(PathFragment.EMPTY_FRAGMENT),Label.WORKSPACE_FILE_NAME);
    return ImmutableList.of(PackageLookupValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER),PackageLookupValue.key(PackageIdentifier.createInMainRepo(PathFragment.EMPTY_FRAGMENT)));
  }
  PathFragment parentPathFragment=currentPathFragment.getParentDirectory();
  return parentPathFragment == null ? ImmutableList.<SkyKey>of() : ImmutableList.of(PackageLookupValue.key(PackageIdentifier.createInMainRepo(parentPathFragment)));
}

Fixed version (ground truth):
/** 
 * Returns package lookup keys for looking up the package root for which there may be a relevant (from the perspective of   {@link #getRBuildFiles})   {@link FileStateValue} node in the graph for{@code originalFileFragment}, which is assumed to be a file path. <p>This is a helper function for   {@link #getFileStateKeysForFileFragments}.
 */
private static Iterable<SkyKey> getPkgLookupKeysForFile(PathFragment originalFileFragment,PathFragment currentPathFragment){
  if (originalFileFragment.equals(currentPathFragment) && originalFileFragment.equals(Label.WORKSPACE_FILE_NAME)) {
    Preconditions.checkState(Label.WORKSPACE_FILE_NAME.getParentDirectory().equals(PathFragment.EMPTY_FRAGMENT),Label.WORKSPACE_FILE_NAME);
    return ImmutableList.of(PackageLookupValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER),PackageLookupValue.key(PackageIdentifier.createInMainRepo(PathFragment.EMPTY_FRAGMENT)));
  }
  PathFragment parentPathFragment=currentPathFragment.getParentDirectory();
  return parentPathFragment == null ? ImmutableList.<SkyKey>of() : ImmutableList.of(PackageLookupValue.key(PackageIdentifier.createInMainRepo(parentPathFragment)));
}