Skip to content

Commit 1857f5a

Browse files
committed
[AIENG-73] Fix Ruby timeout issue by setting HTTP timeouts
1 parent 1662508 commit 1857f5a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

launchable/jar/exe_deploy.jar

262 Bytes
Binary file not shown.

src/main/java/com/launchableinc/ingest/commits/CommitGraphCollector.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.google.common.io.CharStreams;
1111
import org.apache.http.Header;
1212
import org.apache.http.HttpResponse;
13+
import org.apache.http.client.config.RequestConfig;
1314
import org.apache.http.client.methods.CloseableHttpResponse;
1415
import org.apache.http.client.methods.HttpGet;
1516
import org.apache.http.client.methods.HttpPost;
@@ -63,6 +64,7 @@
6364
public class CommitGraphCollector {
6465
private static final Logger logger = LoggerFactory.getLogger(CommitGraphCollector.class);
6566
private static final ObjectMapper objectMapper = new ObjectMapper();
67+
private static final int HTTP_TIMEOUT_MILLISECONDS = 15_000;
6668

6769
/**
6870
* Root repository to start processing.
@@ -114,9 +116,14 @@ private String dumpHeaderAsJson(Header[] headers) throws JsonProcessingException
114116
/** Transfers the commits to the remote endpoint. */
115117
public void transfer(URL service, Authenticator authenticator) throws IOException {
116118
URL url;
119+
RequestConfig config = RequestConfig.custom()
120+
.setConnectTimeout(HTTP_TIMEOUT_MILLISECONDS)
121+
.setConnectionRequestTimeout(HTTP_TIMEOUT_MILLISECONDS)
122+
.setSocketTimeout(HTTP_TIMEOUT_MILLISECONDS).build();
117123
try (CloseableHttpClient client =
118124
HttpClientBuilder.create()
119125
.useSystemProperties()
126+
.setDefaultRequestConfig(config)
120127
.setDefaultHeaders(authenticator.getAuthenticationHeaders())
121128
.build()) {
122129
url = new URL(service, "latest");

0 commit comments

Comments
 (0)