aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2016-07-13 17:01:55 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2016-07-13 18:07:38 +0200
commit10c0d319d02d984c2a075311006434ff3c8251f5 (patch)
treea972a63fcb76a8e4aeac35278144e739e7b5b668 /sonar-ws
parent31f83fbcab419d16c5911583784d6cf780f8c6cf (diff)
downloadsonarqube-10c0d319d02d984c2a075311006434ff3c8251f5.tar.gz
sonarqube-10c0d319d02d984c2a075311006434ff3c8251f5.zip
Fix close connection
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java
index ce412f69de8..0532e9f70f8 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/OkHttpResponse.java
@@ -20,6 +20,8 @@
package org.sonarqube.ws.client;
import okhttp3.Response;
+import okhttp3.ResponseBody;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
@@ -65,12 +67,18 @@ class OkHttpResponse extends BaseResponse {
return okResponse.body().charStream();
}
+ /**
+ * Get body content as a String. This response will be automatically closed.
+ */
@Override
public String content() {
+ ResponseBody body = okResponse.body();
try {
- return okResponse.body().string();
+ return body.string();
} catch (IOException e) {
throw fail(e);
+ } finally {
+ body.close();
}
}