Skip to content

Commit

Permalink
Downloader: Treat 502 as recoverable HTTP error.
Browse files Browse the repository at this point in the history
GitHub releases sometimes fails with a 502 Bad Gateway error, as an internal request times out.
We want to retry these requests, so treat the 502 errors as the other 500s.

Fixes bazelbuild#23334

Closes bazelbuild#23378.

PiperOrigin-RevId: 666244539
Change-Id: I2ed02ed9ecb3a7378c4d29b5ec5b96358e289779
  • Loading branch information
criemen authored and bazel-io committed Aug 22, 2024
1 parent 60cbce1 commit e6089ca
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ URLConnection connect(
throw new IOException(describeHttpResponse(connection));
} else if (code < 500 // 4xx means client seems to have erred quoth RFC7231 § 6.5
|| code == 501 // Server doesn't support function quoth RFC7231 § 6.6.2
|| code == 502 // Host not configured on server cf. RFC7231 § 6.6.3
|| code == 505) { // Server refuses to support version quoth RFC7231 § 6.6.6
// This is a permanent error so we're not going to retry.
readAllBytesAndClose(connection.getErrorStream());
Expand All @@ -214,7 +213,7 @@ URLConnection connect(
}
throw new UnrecoverableHttpException(describeHttpResponse(connection));
} else {
// However we will retry on some 5xx errors, particularly 500 and 503.
// However we will retry on some 5xx errors, particularly 500, 502 and 503.
throw new IOException(describeHttpResponse(connection));
}
} catch (UnrecoverableHttpException | FileNotFoundException e) {
Expand Down

0 comments on commit e6089ca

Please sign in to comment.