Program: 53073
Project: 53073
Buggy source:
@Override public CacheResult fetchImpl(RuleKey ruleKey,LazyPath output,HttpArtifactCacheEvent.Finished.Builder eventBuilder) throws IOException {
  BuckCacheFetchRequest fetchRequest=new BuckCacheFetchRequest();
  BuckCacheRequest cacheRequest=new BuckCacheRequest();
  cacheRequest.setType(BuckCacheRequestType.FETCH);
  cacheRequest.setFetchRequest(fetchRequest);
  final ThriftArtifactCacheProtocol.Request request=ThriftArtifactCacheProtocol.createRequest(PROTOCOL,cacheRequest);
  Request.Builder builder=toOkHttpRequest(request);
  try (HttpResponse httpResponse=fetchClient.makeRequest(hybridThriftEndpoint,builder)){
    if (httpResponse.code() != 200) {
      String message=String.format("String_Node_Str" + "String_Node_Str",httpResponse.code(),httpResponse.requestUrl(),ruleKey.toString());
      LOG.error(message);
      return CacheResult.error(name,message);
    }
    try (ThriftArtifactCacheProtocol.Response response=ThriftArtifactCacheProtocol.parseResponse(PROTOCOL,httpResponse.getBody())){
      BuckCacheResponse cacheResponse=response.getThriftData();
      if (!cacheResponse.isWasSuccessful()) {
        return CacheResult.error(name,cacheResponse.getErrorMessage());
      }
      BuckCacheFetchResponse fetchResponse=cacheResponse.getFetchResponse();
      if (!fetchResponse.isArtifactExists()) {
        return CacheResult.miss();
      }
      Path tmp=createTempFileForDownload();
      ThriftArtifactCacheProtocol.Response.ReadPayloadInfo readResult=null;
      try (OutputStream tmpFile=projectFilesystem.newFileOutputStream(tmp)){
        readResult=response.readPayload(tmpFile);
      }
       ArtifactMetadata metadata=fetchResponse.getMetadata();
      if (!metadata.isSetArtifactPayloadCrc32()) {
        String msg="String_Node_Str";
        LOG.error(msg);
        return CacheResult.error(name,msg);
      }
      if (readResult.getCrc32Hash() != fetchResponse.getMetadata().getArtifactPayloadCrc32()) {
        String msg=String.format("String_Node_Str",fetchResponse.getMetadata().getArtifactPayloadCrc32(),readResult.getCrc32Hash());
        LOG.error(msg);
        return CacheResult.error(name,msg);
      }
      projectFilesystem.move(tmp,output.get(),StandardCopyOption.REPLACE_EXISTING);
      return CacheResult.hit(name,ImmutableMap.copyOf(fetchResponse.getMetadata().getMetadata()),readResult.getBytesRead());
    }
   }
 }

Fixed version (ground truth):
@Override public CacheResult fetchImpl(RuleKey ruleKey,LazyPath output,HttpArtifactCacheEvent.Finished.Builder eventBuilder) throws IOException {
  BuckCacheFetchRequest fetchRequest=new BuckCacheFetchRequest();
  com.facebook.buck.artifact_cache.thrift.RuleKey thriftRuleKey=new com.facebook.buck.artifact_cache.thrift.RuleKey();
  thriftRuleKey.setHashString(ruleKey.getHashCode().toString());
  fetchRequest.setRuleKey(thriftRuleKey);
  BuckCacheRequest cacheRequest=new BuckCacheRequest();
  cacheRequest.setType(BuckCacheRequestType.FETCH);
  cacheRequest.setFetchRequest(fetchRequest);
  final ThriftArtifactCacheProtocol.Request request=ThriftArtifactCacheProtocol.createRequest(PROTOCOL,cacheRequest);
  Request.Builder builder=toOkHttpRequest(request);
  try (HttpResponse httpResponse=fetchClient.makeRequest(hybridThriftEndpoint,builder)){
    if (httpResponse.code() != 200) {
      String message=String.format("String_Node_Str" + "String_Node_Str",httpResponse.code(),httpResponse.requestUrl(),ruleKey.toString());
      LOG.error(message);
      return CacheResult.error(name,message);
    }
    try (ThriftArtifactCacheProtocol.Response response=ThriftArtifactCacheProtocol.parseResponse(PROTOCOL,httpResponse.getBody())){
      BuckCacheResponse cacheResponse=response.getThriftData();
      if (!cacheResponse.isWasSuccessful()) {
        return CacheResult.error(name,cacheResponse.getErrorMessage());
      }
      BuckCacheFetchResponse fetchResponse=cacheResponse.getFetchResponse();
      if (!fetchResponse.isArtifactExists()) {
        return CacheResult.miss();
      }
      Path tmp=createTempFileForDownload();
      ThriftArtifactCacheProtocol.Response.ReadPayloadInfo readResult=null;
      try (OutputStream tmpFile=projectFilesystem.newFileOutputStream(tmp)){
        readResult=response.readPayload(tmpFile);
      }
       ArtifactMetadata metadata=fetchResponse.getMetadata();
      if (!metadata.isSetArtifactPayloadCrc32()) {
        String msg="String_Node_Str";
        LOG.error(msg);
        return CacheResult.error(name,msg);
      }
      if (!readResult.getCrc32Hash().equals(fetchResponse.getMetadata().getArtifactPayloadCrc32())) {
        String msg=String.format("String_Node_Str",fetchResponse.getMetadata().getArtifactPayloadCrc32(),readResult.getCrc32Hash());
        LOG.error(msg);
        return CacheResult.error(name,msg);
      }
      projectFilesystem.move(tmp,output.get(),StandardCopyOption.REPLACE_EXISTING);
      return CacheResult.hit(name,ImmutableMap.copyOf(fetchResponse.getMetadata().getMetadata()),readResult.getBytesRead());
    }
   }
 }