aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-03-24 20:29:37 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-03-25 21:53:39 +0000
commit68e193288e2306c763a719102531da65bf417cbc (patch)
tree7b69fcc321d2cf8eca77c115895f80278e4e2c21 /src/main/java
parenta25fa9f38fe4d38eccec63f5275ef2fcc61700cd (diff)
Add timeout to dash connections
Fixes #545. -- MOS_MIGRATED_REVID=118059971
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java b/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java
index 222223db29..ac46df5d51 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java
@@ -45,6 +45,9 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
import java.io.File;
import java.io.FileInputStream;
@@ -308,7 +311,11 @@ public class DashModule extends BlazeModule {
private void sendMessage(final String suffix, final HttpEntity message)
throws SenderException {
- HttpClient httpClient = new DefaultHttpClient();
+ HttpParams httpParams = new BasicHttpParams();
+ HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
+ HttpConnectionParams.setSoTimeout(httpParams, 5000);
+ HttpClient httpClient = new DefaultHttpClient(httpParams);
+
HttpPost httppost = new HttpPost(url + "/" + suffix + "/" + buildId);
if (message != null) {
httppost.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-protobuf");