Skip to content

Commit 7f56c1c

Browse files
committed
DefaultRequestHandler does not release connections
1 parent 314df6a commit 7f56c1c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/se/walkercrou/places/DefaultRequestHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,25 @@ private String readString(HttpResponse response) throws IOException {
6464

6565
@Override
6666
public InputStream getInputStream(String uri) throws IOException {
67+
HttpGet get = new HttpGet(uri);
6768
try {
68-
HttpGet get = new HttpGet(uri);
6969
return client.execute(get).getEntity().getContent();
7070
} catch (Exception e) {
7171
throw new IOException(e);
72+
} finally {
73+
get.releaseConnection();
7274
}
7375
}
7476

7577
@Override
7678
public String get(String uri) throws IOException {
79+
HttpGet get = new HttpGet(uri);
7780
try {
78-
HttpGet get = new HttpGet(uri);
7981
return readString(client.execute(get));
8082
} catch (Exception e) {
8183
throw new IOException(e);
84+
} finally {
85+
get.releaseConnection();
8286
}
8387
}
8488

@@ -88,6 +92,8 @@ public String post(HttpPost data) throws IOException {
8892
return readString(client.execute(data));
8993
} catch (Exception e) {
9094
throw new IOException(e);
95+
} finally {
96+
data.releaseConnection();
9197
}
9298
}
9399
}

0 commit comments

Comments
 (0)