Skip to content

Commit 2205f08

Browse files
authored
Issue #155: Set the read timeout explicitly in HttpUtil (#156)
1 parent 9aa7016 commit 2205f08

File tree

1 file changed

+6
-1
lines changed
  • dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal

1 file changed

+6
-1
lines changed

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/HttpUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static HttpResult get(URI uri) throws IOException {
8888
connection = (HttpURLConnection) uri.toURL().openConnection();
8989

9090
connection.setRequestMethod("GET");
91-
connection.setReadTimeout(5000);
91+
connection.setReadTimeout(10000);
9292

9393
return new HttpResult(connection);
9494
} finally {
@@ -106,6 +106,7 @@ public static HttpResult post(URI uri, JSONObject payload) throws IOException {
106106
connection = (HttpURLConnection) uri.toURL().openConnection();
107107

108108
connection.setRequestMethod("POST");
109+
connection.setReadTimeout(10000);
109110

110111
if (payload != null) {
111112
connection.setRequestProperty("Content-Type", "application/json");
@@ -130,6 +131,7 @@ public static HttpResult post(URI uri) throws IOException {
130131
try {
131132
connection = (HttpURLConnection) uri.toURL().openConnection();
132133
connection.setRequestMethod("POST");
134+
connection.setReadTimeout(10000);
133135
return new HttpResult(connection);
134136
} finally {
135137
if (connection != null) {
@@ -146,6 +148,7 @@ public static HttpResult put(URI uri) throws IOException {
146148
connection = (HttpURLConnection) uri.toURL().openConnection();
147149

148150
connection.setRequestMethod("PUT");
151+
connection.setReadTimeout(10000);
149152

150153
return new HttpResult(connection);
151154
} finally {
@@ -163,6 +166,7 @@ public static HttpResult head(URI uri) throws IOException {
163166
connection = (HttpURLConnection) uri.toURL().openConnection();
164167

165168
connection.setRequestMethod("HEAD");
169+
connection.setReadTimeout(10000);
166170

167171
return new HttpResult(connection);
168172
} finally {
@@ -180,6 +184,7 @@ public static HttpResult delete(URI uri) throws IOException {
180184
connection = (HttpURLConnection) uri.toURL().openConnection();
181185

182186
connection.setRequestMethod("DELETE");
187+
connection.setReadTimeout(10000);
183188

184189
return new HttpResult(connection);
185190
} finally {

0 commit comments

Comments
 (0)