Skip to content

Commit

Permalink
Retry HTTP download on timeout.
Browse files Browse the repository at this point in the history
Address bazelbuild#20559 (comment).

PiperOrigin-RevId: 649360592
Change-Id: I50ac2ed3b54d6cffb5f96d3f8315279786c4f30f
  • Loading branch information
coeuvre authored and pull[bot] committed Nov 26, 2024
1 parent d54ff98 commit 1048576
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import com.google.devtools.build.lib.remote.common.RemoteCacheClient;
import com.google.devtools.build.lib.remote.common.RemoteExecutionClient;
import com.google.devtools.build.lib.remote.downloader.GrpcRemoteDownloader;
import com.google.devtools.build.lib.remote.http.DownloadTimeoutException;
import com.google.devtools.build.lib.remote.http.HttpException;
import com.google.devtools.build.lib.remote.logging.LoggingInterceptor;
import com.google.devtools.build.lib.remote.logging.RemoteExecutionLog.LogEntry;
Expand Down Expand Up @@ -191,6 +192,8 @@ private static boolean shouldEnableRemoteDownloader(RemoteOptions options) {
boolean retry = false;
if (e instanceof ClosedChannelException) {
retry = true;
} else if (e instanceof DownloadTimeoutException) {
retry = true;
} else if (e instanceof HttpException httpException) {
int status = httpException.response().status().code();
retry =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

import java.io.IOException;

class DownloadTimeoutException extends IOException {
/** Exception thrown when a HTTP download times out. */
public class DownloadTimeoutException extends IOException {

public DownloadTimeoutException(String url, long bytesReceived, long contentLength) {
super(buildMessage(url, bytesReceived, contentLength));
Expand Down

0 comments on commit 1048576

Please sign in to comment.