diff --git a/pom.xml b/pom.xml
index b008da989a..4d623c86fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
github-api
- 1.85
+ 1.86
GitHub API for Java
http://github-api.kohsuke.org/
GitHub API for Java
@@ -16,7 +16,7 @@
scm:git:git@github.com/kohsuke/${project.artifactId}.git
scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git
http://${project.artifactId}.kohsuke.org/
- github-api-1.85
+ github-api-1.86
diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java
index 3cd338b8c2..d7d6239190 100644
--- a/src/main/java/org/kohsuke/github/Requester.java
+++ b/src/main/java/org/kohsuke/github/Requester.java
@@ -36,6 +36,7 @@
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
+import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -57,6 +58,7 @@
import org.apache.commons.lang.StringUtils;
import static java.util.Arrays.asList;
+import java.util.logging.Level;
import static java.util.logging.Level.*;
import static org.kohsuke.github.GitHub.MAPPER;
@@ -579,6 +581,10 @@ private void setRequestMethod(HttpURLConnection uc) throws IOException {
}
private T parse(Class type, T instance) throws IOException {
+ return parse(type, instance, 2);
+ }
+
+ private T parse(Class type, T instance, int timeouts) throws IOException {
InputStreamReader r = null;
int responseCode = -1;
String responseMessage = null;
@@ -609,6 +615,10 @@ private T parse(Class type, T instance) throws IOException {
// to preserve backward compatibility
throw e;
} catch (IOException e) {
+ if (e instanceof SocketTimeoutException && timeouts > 0) {
+ LOGGER.log(Level.INFO, "timed out accessing " + uc.getURL() + "; will try " + timeouts + " more time(s)", e);
+ return parse(type, instance, timeouts - 1);
+ }
throw new HttpException(responseCode, responseMessage, uc.getURL(), e);
} finally {
IOUtils.closeQuietly(r);