Program: 52946
Project: 52946
Buggy source:
private Optional<BuildResult> performManifestBasedCacheFetch(final BuildRule rule,final BuildEngineBuildContext context,BuildInfoRecorder buildInfoRecorder,RuleKeyAndInputs manifestKey) throws IOException {
  Preconditions.checkArgument(useManifestCaching(rule));
  final LazyPath tempFile=new LazyPath(){
    @Override protected Path create() throws IOException {
      return Files.createTempFile("String_Node_Str","String_Node_Str");
    }
  }
;
  CacheResult manifestResult=fetchArtifactForBuildable(manifestKey.getRuleKey(),tempFile,context.getArtifactCache());
  if (!manifestResult.getType().isSuccess()) {
    return Optional.empty();
  }
  Path manifestPath=getManifestPath(rule);
  rule.getProjectFilesystem().deleteFileAtPathIfExists(manifestPath);
  rule.getProjectFilesystem().createParentDirs(manifestPath);
  try (OutputStream outputStream=rule.getProjectFilesystem().newFileOutputStream(manifestPath);InputStream inputStream=new GZIPInputStream(new BufferedInputStream(Files.newInputStream(tempFile.get())))){
    ByteStreams.copy(inputStream,outputStream);
  }
   Files.delete(tempFile.get());
  Manifest manifest;
  try (InputStream input=rule.getProjectFilesystem().newFileInputStream(manifestPath)){
    manifest=new Manifest(input);
  }
   Optional<RuleKey> ruleKey=manifest.lookup(fileHashCache,pathResolver,manifestKey.getInputs());
  if (!ruleKey.isPresent()) {
    return Optional.empty();
  }
  CacheResult cacheResult=tryToFetchArtifactFromBuildCacheAndOverlayOnTopOfProjectFilesystem(rule,ruleKey.get(),context.getArtifactCache(),rule.getProjectFilesystem(),context);
  if (cacheResult.getType().isSuccess()) {
    fillMissingBuildMetadataFromCache(cacheResult,buildInfoRecorder,BuildInfo.MetadataKey.ORIGIN_BUILD_ID,BuildInfo.MetadataKey.DEP_FILE_RULE_KEY,BuildInfo.MetadataKey.DEP_FILE);
    return Optional.of(BuildResult.success(rule,BuildRuleSuccessType.FETCHED_FROM_CACHE_MANIFEST_BASED,cacheResult));
  }
  return Optional.empty();
}

Fixed version (ground truth):
private Optional<BuildResult> performManifestBasedCacheFetch(final BuildRule rule,final BuildEngineBuildContext context,BuildInfoRecorder buildInfoRecorder,RuleKeyAndInputs manifestKey) throws IOException {
  Preconditions.checkArgument(useManifestCaching(rule));
  final LazyPath tempFile=new LazyPath(){
    @Override protected Path create() throws IOException {
      return Files.createTempFile("String_Node_Str","String_Node_Str");
    }
  }
;
  CacheResult manifestResult=fetchArtifactForBuildable(manifestKey.getRuleKey(),tempFile,context.getArtifactCache());
  if (!manifestResult.getType().isSuccess()) {
    return Optional.empty();
  }
  Path manifestPath=getManifestPath(rule);
  rule.getProjectFilesystem().deleteFileAtPathIfExists(manifestPath);
  rule.getProjectFilesystem().createParentDirs(manifestPath);
  try (OutputStream outputStream=rule.getProjectFilesystem().newFileOutputStream(manifestPath);InputStream inputStream=new GZIPInputStream(new BufferedInputStream(Files.newInputStream(tempFile.get())))){
    ByteStreams.copy(inputStream,outputStream);
  }
   Files.delete(tempFile.get());
  Manifest manifest;
  try (InputStream input=rule.getProjectFilesystem().newFileInputStream(manifestPath)){
    manifest=new Manifest(input);
  }
   Preconditions.checkState(manifest.getKey().equals(manifestKey.getRuleKey()),"String_Node_Str",rule.getBuildTarget(),manifestKey.getRuleKey(),manifest.getKey());
  Optional<RuleKey> ruleKey=manifest.lookup(fileHashCache,pathResolver,manifestKey.getInputs());
  if (!ruleKey.isPresent()) {
    return Optional.empty();
  }
  CacheResult cacheResult=tryToFetchArtifactFromBuildCacheAndOverlayOnTopOfProjectFilesystem(rule,ruleKey.get(),context.getArtifactCache(),rule.getProjectFilesystem(),context);
  if (cacheResult.getType().isSuccess()) {
    fillMissingBuildMetadataFromCache(cacheResult,buildInfoRecorder,BuildInfo.MetadataKey.ORIGIN_BUILD_ID,BuildInfo.MetadataKey.DEP_FILE_RULE_KEY,BuildInfo.MetadataKey.DEP_FILE);
    return Optional.of(BuildResult.success(rule,BuildRuleSuccessType.FETCHED_FROM_CACHE_MANIFEST_BASED,cacheResult));
  }
  return Optional.empty();
}