Skip to content

Commit

Permalink
Throw connection issue immediately hub4j#159
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyaSha committed Mar 16, 2015
1 parent dcc3b7f commit 2f9c321
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/java/org/kohsuke/github/Requester.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,18 @@ private InputStream wrapStream(HttpURLConnection uc, InputStream in) throws IOEx
* Otherwise throw an exception reporting an error.
*/
/*package*/ void handleApiError(IOException e, HttpURLConnection uc) throws IOException {
if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) {
// API limit reached. wait 10 secs and return normally
try {
Thread.sleep(10000);
return;
} catch (InterruptedException _) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
}
// Disable this check, because it causes "infinite" thread usage when:
// 1) set bad password you can't apply changed without interrupting thread
// 2) exhausted limit will cause lock upto 1h until reset time
// if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) {
// // API limit reached. wait 10 secs and return normally
// try {
// Thread.sleep(10000);
// return;
// } catch (InterruptedException _) {
// throw (InterruptedIOException)new InterruptedIOException().initCause(e);
// }
// }

if (e instanceof FileNotFoundException)
throw e; // pass through 404 Not Found to allow the caller to handle it intelligently
Expand Down

0 comments on commit 2f9c321

Please sign in to comment.