Program: 52951
Project: 52951
Buggy source:
@Test public void manifestBasedCacheHit() throws Exception {
  DefaultDependencyFileRuleKeyFactory depFilefactory=new DefaultDependencyFileRuleKeyFactory(FIELD_LOADER,fileHashCache,pathResolver,ruleFinder);
  BuildTarget target=BuildTargetFactory.newInstance("String_Node_Str");
  BuildRuleParams params=new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(filesystem).build();
  final SourcePath input=new PathSourcePath(filesystem,filesystem.getRootPath().getFileSystem().getPath("String_Node_Str"));
  filesystem.touch(pathResolver.getRelativePath(input));
  final Path output=Paths.get("String_Node_Str");
  DepFileBuildRule rule=new DepFileBuildRule(params){
    @AddToRuleKey private final SourcePath path=input;
    @Override public ImmutableList<Step> getBuildSteps(    BuildContext context,    BuildableContext buildableContext){
      return ImmutableList.of(new WriteFileStep(filesystem,"String_Node_Str",output,false));
    }
    @Override public Predicate<SourcePath> getCoveredByDepFilePredicate(){
      return (      SourcePath path) -> true;
    }
    @Override public Predicate<SourcePath> getExistenceOfInterestPredicate(){
      return (      SourcePath path) -> false;
    }
    @Override public ImmutableList<SourcePath> getInputsAfterBuildingLocally(    BuildContext context){
      return ImmutableList.of(input);
    }
    @Override public SourcePath getSourcePathToOutput(){
      return new ExplicitBuildTargetSourcePath(getBuildTarget(),output);
    }
  }
;
  CachingBuildEngine cachingBuildEngine=cachingBuildEngineFactory().setDepFiles(CachingBuildEngine.DepFiles.CACHE).setRuleKeyFactories(RuleKeyFactories.of(defaultRuleKeyFactory,inputBasedRuleKeyFactory,depFilefactory)).build();
  RuleKey ruleKey=defaultRuleKeyFactory.build(rule);
  RuleKeyAndInputs depFileKey=depFilefactory.build(rule,ImmutableList.of(DependencyFileEntry.fromSourcePath(input,pathResolver)));
  Manifest manifest=new Manifest();
  manifest.addEntry(fileHashCache,depFileKey.getRuleKey(),pathResolver,ImmutableSet.of(input),ImmutableSet.of(input));
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  try (GZIPOutputStream outputStream=new GZIPOutputStream(byteArrayOutputStream)){
    manifest.serialize(outputStream);
  }
   cache.store(ArtifactInfo.builder().addRuleKeys(cachingBuildEngine.getManifestRuleKey(rule,buildContext.getEventBus()).get()).build(),byteArrayOutputStream.toByteArray());
  Path artifact=tmp.newFile("String_Node_Str");
  writeEntriesToZip(artifact,ImmutableMap.of(BuildInfo.getPathToMetadataDirectory(target,filesystem).resolve(BuildInfo.MetadataKey.RECORDED_PATHS),ObjectMappers.WRITER.writeValueAsString(ImmutableList.of(output.toString())),output,"String_Node_Str"));
  cache.store(ArtifactInfo.builder().addRuleKeys(depFileKey.getRuleKey()).putMetadata(BuildInfo.MetadataKey.ORIGIN_BUILD_ID,buildContext.getBuildId().toString()).putMetadata(BuildInfo.MetadataKey.DEP_FILE_RULE_KEY,depFileKey.getRuleKey().toString()).putMetadata(BuildInfo.MetadataKey.DEP_FILE,ObjectMappers.WRITER.writeValueAsString(depFileKey.getInputs().stream().map(pathResolver::getRelativePath).collect(MoreCollectors.toImmutableList()))).build(),BorrowablePath.notBorrowablePath(artifact));
  BuildResult result=cachingBuildEngine.build(buildContext,TestExecutionContext.newInstance(),rule).get();
  assertThat(getSuccess(result),equalTo(BuildRuleSuccessType.FETCHED_FROM_CACHE_MANIFEST_BASED));
  for (  RuleKey key : ImmutableSet.of(ruleKey,depFileKey.getRuleKey())) {
    LazyPath fetchedArtifact=LazyPath.ofInstance(tmp.newFile("String_Node_Str"));
    CacheResult cacheResult=cache.fetch(key,fetchedArtifact);
    assertThat(cacheResult.getType(),equalTo(CacheResultType.HIT));
    assertThat(cacheResult.getMetadata().get(BuildInfo.MetadataKey.RULE_KEY),equalTo(ruleKey.toString()));
    assertThat(cacheResult.getMetadata().get(BuildInfo.MetadataKey.DEP_FILE_RULE_KEY),equalTo(depFileKey.getRuleKey().toString()));
    assertThat(cacheResult.getMetadata().get(BuildInfo.MetadataKey.DEP_FILE),equalTo(ObjectMappers.WRITER.writeValueAsString(depFileKey.getInputs().stream().map(pathResolver::getRelativePath).collect(MoreCollectors.toImmutableList()))));
    Files.delete(fetchedArtifact.get());
  }
}

Fixed version (ground truth):
@Test public void manifestBasedCacheHit() throws Exception {
  DefaultDependencyFileRuleKeyFactory depFilefactory=new DefaultDependencyFileRuleKeyFactory(FIELD_LOADER,fileHashCache,pathResolver,ruleFinder);
  BuildTarget target=BuildTargetFactory.newInstance("String_Node_Str");
  BuildRuleParams params=new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(filesystem).build();
  final SourcePath input=new PathSourcePath(filesystem,filesystem.getRootPath().getFileSystem().getPath("String_Node_Str"));
  filesystem.touch(pathResolver.getRelativePath(input));
  final Path output=Paths.get("String_Node_Str");
  DepFileBuildRule rule=new DepFileBuildRule(params){
    @AddToRuleKey private final SourcePath path=input;
    @Override public ImmutableList<Step> getBuildSteps(    BuildContext context,    BuildableContext buildableContext){
      return ImmutableList.of(new WriteFileStep(filesystem,"String_Node_Str",output,false));
    }
    @Override public Predicate<SourcePath> getCoveredByDepFilePredicate(){
      return (      SourcePath path) -> true;
    }
    @Override public Predicate<SourcePath> getExistenceOfInterestPredicate(){
      return (      SourcePath path) -> false;
    }
    @Override public ImmutableList<SourcePath> getInputsAfterBuildingLocally(    BuildContext context){
      return ImmutableList.of(input);
    }
    @Override public SourcePath getSourcePathToOutput(){
      return new ExplicitBuildTargetSourcePath(getBuildTarget(),output);
    }
  }
;
  CachingBuildEngine cachingBuildEngine=cachingBuildEngineFactory().setDepFiles(CachingBuildEngine.DepFiles.CACHE).setRuleKeyFactories(RuleKeyFactories.of(defaultRuleKeyFactory,inputBasedRuleKeyFactory,depFilefactory)).build();
  RuleKey ruleKey=defaultRuleKeyFactory.build(rule);
  RuleKeyAndInputs depFileKey=depFilefactory.build(rule,ImmutableList.of(DependencyFileEntry.fromSourcePath(input,pathResolver)));
  Manifest manifest=new Manifest(depFilefactory.buildManifestKey(rule).getRuleKey());
  manifest.addEntry(fileHashCache,depFileKey.getRuleKey(),pathResolver,ImmutableSet.of(input),ImmutableSet.of(input));
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  try (GZIPOutputStream outputStream=new GZIPOutputStream(byteArrayOutputStream)){
    manifest.serialize(outputStream);
  }
   cache.store(ArtifactInfo.builder().addRuleKeys(cachingBuildEngine.getManifestRuleKey(rule,buildContext.getEventBus()).get()).build(),byteArrayOutputStream.toByteArray());
  Path artifact=tmp.newFile("String_Node_Str");
  writeEntriesToZip(artifact,ImmutableMap.of(BuildInfo.getPathToMetadataDirectory(target,filesystem).resolve(BuildInfo.MetadataKey.RECORDED_PATHS),ObjectMappers.WRITER.writeValueAsString(ImmutableList.of(output.toString())),output,"String_Node_Str"));
  cache.store(ArtifactInfo.builder().addRuleKeys(depFileKey.getRuleKey()).putMetadata(BuildInfo.MetadataKey.ORIGIN_BUILD_ID,buildContext.getBuildId().toString()).putMetadata(BuildInfo.MetadataKey.DEP_FILE_RULE_KEY,depFileKey.getRuleKey().toString()).putMetadata(BuildInfo.MetadataKey.DEP_FILE,ObjectMappers.WRITER.writeValueAsString(depFileKey.getInputs().stream().map(pathResolver::getRelativePath).collect(MoreCollectors.toImmutableList()))).build(),BorrowablePath.notBorrowablePath(artifact));
  BuildResult result=cachingBuildEngine.build(buildContext,TestExecutionContext.newInstance(),rule).get();
  assertThat(getSuccess(result),equalTo(BuildRuleSuccessType.FETCHED_FROM_CACHE_MANIFEST_BASED));
  for (  RuleKey key : ImmutableSet.of(ruleKey,depFileKey.getRuleKey())) {
    LazyPath fetchedArtifact=LazyPath.ofInstance(tmp.newFile("String_Node_Str"));
    CacheResult cacheResult=cache.fetch(key,fetchedArtifact);
    assertThat(cacheResult.getType(),equalTo(CacheResultType.HIT));
    assertThat(cacheResult.getMetadata().get(BuildInfo.MetadataKey.RULE_KEY),equalTo(ruleKey.toString()));
    assertThat(cacheResult.getMetadata().get(BuildInfo.MetadataKey.DEP_FILE_RULE_KEY),equalTo(depFileKey.getRuleKey().toString()));
    assertThat(cacheResult.getMetadata().get(BuildInfo.MetadataKey.DEP_FILE),equalTo(ObjectMappers.WRITER.writeValueAsString(depFileKey.getInputs().stream().map(pathResolver::getRelativePath).collect(MoreCollectors.toImmutableList()))));
    Files.delete(fetchedArtifact.get());
  }
}