mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
As suggested in the code review, handle exceptions and setup the connection
This commit is contained in:
@@ -919,6 +919,7 @@ class Requester {
|
||||
} catch (InterruptedException ie) {
|
||||
throw (IOException) new InterruptedIOException().initCause(e);
|
||||
}
|
||||
uc = setupConnection(uc.getURL());
|
||||
return parse(type, instance, timeouts - 1);
|
||||
}
|
||||
throw new HttpException(responseCode, responseMessage, uc.getURL(), e);
|
||||
@@ -938,7 +939,11 @@ class Requester {
|
||||
// scenarios. If GitHub ever fixes their issue and/or begins providing accurate ETags to
|
||||
// their 404 responses, this will result in at worst two requests being made for each 404
|
||||
// responses. However, only the second request will count against rate limit.
|
||||
int responseCode = uc.getResponseCode();
|
||||
int responseCode = 0;
|
||||
try {
|
||||
uc.getResponseCode();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (responseCode == 404 && Objects.equals(uc.getRequestMethod(), "GET") && uc.getHeaderField("ETag") != null
|
||||
&& !Objects.equals(uc.getRequestProperty("Cache-Control"), "no-cache")) {
|
||||
uc = setupConnection(uc.getURL());
|
||||
|
||||
Reference in New Issue
Block a user