Program: 53000
Project: 53000
Buggy source:
private Optional<BuildResult> performManifestBasedCacheFetch(final BuildRule rule,final BuildEngineBuildContext context,final BuildInfoRecorder buildInfoRecorder) throws IOException {
  if (!useManifestCaching(rule)) {
    return Optional.empty();
  }
  final Optional<Pair<RuleKey,ImmutableSet<SourcePath>>> manifestKey=ruleKeyFactories.getUnchecked(rule.getProjectFilesystem()).depFileRuleKeyFactory.buildManifestKey((SupportsDependencyFileRuleKey)rule);
  if (!manifestKey.isPresent()) {
    buildInfoRecorder.addBuildMetadata(BuildInfo.MetadataKey.MANIFEST_KEY,manifestKey.get().getFirst().toString());
    return Optional.empty();
  }
  final LazyPath tempFile=new LazyPath(){
    @Override protected Path create() throws IOException {
      return Files.createTempFile("String_Node_Str","String_Node_Str");
    }
  }
;
  CacheResult manifestResult=fetchArtifactForBuildable(manifestKey.get().getFirst(),tempFile,context.getArtifactCache(),buildInfoRecorder);
  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(fileHashCaches.getUnchecked(rule.getProjectFilesystem()),pathResolver,manifestKey.get().getSecond());
  if (!ruleKey.isPresent()) {
    return Optional.empty();
  }
  CacheResult cacheResult=tryToFetchArtifactFromBuildCacheAndOverlayOnTopOfProjectFilesystem(rule,ruleKey.get(),buildInfoRecorder,context.getArtifactCache(),rule.getProjectFilesystem(),context);
  if (cacheResult.getType().isSuccess()) {
    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,final BuildInfoRecorder buildInfoRecorder) throws IOException {
  if (!useManifestCaching(rule)) {
    return Optional.empty();
  }
  final Optional<Pair<RuleKey,ImmutableSet<SourcePath>>> manifestKey=ruleKeyFactories.getUnchecked(rule.getProjectFilesystem()).depFileRuleKeyFactory.buildManifestKey((SupportsDependencyFileRuleKey)rule);
  if (!manifestKey.isPresent()) {
    return Optional.empty();
  }
  buildInfoRecorder.addBuildMetadata(BuildInfo.MetadataKey.MANIFEST_KEY,manifestKey.get().getFirst().toString());
  final LazyPath tempFile=new LazyPath(){
    @Override protected Path create() throws IOException {
      return Files.createTempFile("String_Node_Str","String_Node_Str");
    }
  }
;
  CacheResult manifestResult=fetchArtifactForBuildable(manifestKey.get().getFirst(),tempFile,context.getArtifactCache(),buildInfoRecorder);
  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(fileHashCaches.getUnchecked(rule.getProjectFilesystem()),pathResolver,manifestKey.get().getSecond());
  if (!ruleKey.isPresent()) {
    return Optional.empty();
  }
  CacheResult cacheResult=tryToFetchArtifactFromBuildCacheAndOverlayOnTopOfProjectFilesystem(rule,ruleKey.get(),buildInfoRecorder,context.getArtifactCache(),rule.getProjectFilesystem(),context);
  if (cacheResult.getType().isSuccess()) {
    return Optional.of(BuildResult.success(rule,BuildRuleSuccessType.FETCHED_FROM_CACHE_MANIFEST_BASED,cacheResult));
  }
  return Optional.empty();
}