|
10 | 10 | import com.google.common.io.CharStreams; |
11 | 11 | import org.apache.http.Header; |
12 | 12 | import org.apache.http.HttpResponse; |
| 13 | +import org.apache.http.client.config.RequestConfig; |
13 | 14 | import org.apache.http.client.methods.CloseableHttpResponse; |
14 | 15 | import org.apache.http.client.methods.HttpGet; |
15 | 16 | import org.apache.http.client.methods.HttpPost; |
|
63 | 64 | public class CommitGraphCollector { |
64 | 65 | private static final Logger logger = LoggerFactory.getLogger(CommitGraphCollector.class); |
65 | 66 | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| 67 | + private static final int HTTP_TIMEOUT_MILLISECONDS = 15_000; |
66 | 68 |
|
67 | 69 | /** |
68 | 70 | * Root repository to start processing. |
@@ -114,9 +116,14 @@ private String dumpHeaderAsJson(Header[] headers) throws JsonProcessingException |
114 | 116 | /** Transfers the commits to the remote endpoint. */ |
115 | 117 | public void transfer(URL service, Authenticator authenticator) throws IOException { |
116 | 118 | URL url; |
| 119 | + RequestConfig config = RequestConfig.custom() |
| 120 | + .setConnectTimeout(HTTP_TIMEOUT_MILLISECONDS) |
| 121 | + .setConnectionRequestTimeout(HTTP_TIMEOUT_MILLISECONDS) |
| 122 | + .setSocketTimeout(HTTP_TIMEOUT_MILLISECONDS).build(); |
117 | 123 | try (CloseableHttpClient client = |
118 | 124 | HttpClientBuilder.create() |
119 | 125 | .useSystemProperties() |
| 126 | + .setDefaultRequestConfig(config) |
120 | 127 | .setDefaultHeaders(authenticator.getAuthenticationHeaders()) |
121 | 128 | .build()) { |
122 | 129 | url = new URL(service, "latest"); |
|
0 commit comments