Skip to content

Commit bb88a6a

Browse files
authored
Fix rate limit exception in update checker (#4731)
1 parent 739600e commit bb88a6a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Essentials/src/main/java/com/earth2me/essentials/updatecheck/UpdateChecker.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public CompletableFuture<RemoteVersion> fetchLatestRelease() {
9696
// Locally built?
9797
pendingReleaseFuture.complete(cachedRelease = new RemoteVersion(BranchStatus.UNKNOWN));
9898
break catchBlock;
99-
}
100-
if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
101-
// Github is down
99+
} else if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR || connection.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) {
100+
// GitHub is down or rate limit exceeded
102101
pendingReleaseFuture.complete(new RemoteVersion(BranchStatus.ERROR));
103102
break catchBlock;
104103
}
@@ -146,8 +145,7 @@ private RemoteVersion fetchDistance(final String head, final String hash) {
146145
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
147146
// Locally built?
148147
return new RemoteVersion(BranchStatus.UNKNOWN);
149-
}
150-
if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR || connection.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) {
148+
} else if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR || connection.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) {
151149
// GitHub is down or we hit a local rate limit
152150
return new RemoteVersion(BranchStatus.ERROR);
153151
}

0 commit comments

Comments
 (0)