Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.

Commit abd3616

Browse files
committed
storage-client cleanup or reuse of existing client not properly working. quick'n'dirty fix for now use new client for every call and make sure cleanup is executed
1 parent 104c473 commit abd3616

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

backmeup-storage-client/src/main/java/org/backmeup/storage/client/BackmeupStorageClient.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,19 @@ public void addFileAccessRights(String accessToken, String ownerId, String fileP
211211
}
212212

213213
HttpPost httpPost = new HttpPost(full);
214-
CloseableHttpResponse response = this.client.execute(httpPost);
214+
CloseableHttpClient myClient = createClient();
215+
CloseableHttpResponse response = myClient.execute(httpPost);
216+
try {
217+
//
218+
} catch (Exception e) {
219+
220+
} finally {
221+
try {
222+
response.close();
223+
myClient.close();
224+
} catch (IOException e) {
225+
}
226+
}
215227

216228
int status = response.getStatusLine().getStatusCode();
217229
if (HttpStatus.SC_OK != status) {
@@ -236,13 +248,25 @@ public void removeFileAccessRights(String accessToken, String ownerId, String fi
236248
}
237249

238250
HttpDelete httpDelete = new HttpDelete(full);
239-
CloseableHttpResponse response = this.client.execute(httpDelete);
251+
CloseableHttpClient myClient = createClient();
252+
CloseableHttpResponse response = myClient.execute(httpDelete);
240253

241254
int status = response.getStatusLine().getStatusCode();
242255
if (HttpStatus.SC_OK != status) {
243256
LOGGER.error("Request failed with status code: " + status);
244257
throw new IOException("Request failed with status code: " + status);
245258
}
259+
try {
260+
//
261+
} catch (Exception e) {
262+
263+
} finally {
264+
try {
265+
response.close();
266+
myClient.close();
267+
} catch (IOException e) {
268+
}
269+
}
246270
}
247271

248272
@Override
@@ -260,27 +284,33 @@ public boolean hasFileAccessRights(String accessToken, String ownerId, String fi
260284
}
261285

262286
HttpGet httpGet = new HttpGet(full);
263-
//httpGet.addHeader("Authorization", accessToken);
264-
CloseableHttpResponse response = this.client.execute(httpGet);
287+
288+
CloseableHttpClient myClient = createClient();
289+
CloseableHttpResponse response = myClient.execute(httpGet);
265290

266291
int status = response.getStatusLine().getStatusCode();
267292
if (HttpStatus.SC_OK != status) {
268293
LOGGER.error("Request failed with status code: " + status);
269294
throw new IOException("Request failed with status code: " + status);
270295
}
271-
272296
try {
273297
HttpEntity respEntity = response.getEntity();
274298
ObjectMapper mapper = createJsonMapper();
275299
Boolean hasAccess = mapper.readValue(respEntity.getContent(), Boolean.class);
276300
// release all resources held by httpentity
277301
EntityUtils.consume(respEntity);
302+
response.close();
303+
myClient.close();
278304
return hasAccess;
279305
} catch (Exception e) {
280306
LOGGER.error("", e);
281307
throw new IOException(e);
282308
} finally {
283-
response.close();
309+
try {
310+
response.close();
311+
myClient.close();
312+
} catch (IOException e) {
313+
}
284314
}
285315
}
286316

0 commit comments

Comments
 (0)