@@ -211,7 +211,19 @@ public void addFileAccessRights(String accessToken, String ownerId, String fileP
211
211
}
212
212
213
213
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
+ }
215
227
216
228
int status = response .getStatusLine ().getStatusCode ();
217
229
if (HttpStatus .SC_OK != status ) {
@@ -236,13 +248,25 @@ public void removeFileAccessRights(String accessToken, String ownerId, String fi
236
248
}
237
249
238
250
HttpDelete httpDelete = new HttpDelete (full );
239
- CloseableHttpResponse response = this .client .execute (httpDelete );
251
+ CloseableHttpClient myClient = createClient ();
252
+ CloseableHttpResponse response = myClient .execute (httpDelete );
240
253
241
254
int status = response .getStatusLine ().getStatusCode ();
242
255
if (HttpStatus .SC_OK != status ) {
243
256
LOGGER .error ("Request failed with status code: " + status );
244
257
throw new IOException ("Request failed with status code: " + status );
245
258
}
259
+ try {
260
+ //
261
+ } catch (Exception e ) {
262
+
263
+ } finally {
264
+ try {
265
+ response .close ();
266
+ myClient .close ();
267
+ } catch (IOException e ) {
268
+ }
269
+ }
246
270
}
247
271
248
272
@ Override
@@ -260,27 +284,33 @@ public boolean hasFileAccessRights(String accessToken, String ownerId, String fi
260
284
}
261
285
262
286
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 );
265
290
266
291
int status = response .getStatusLine ().getStatusCode ();
267
292
if (HttpStatus .SC_OK != status ) {
268
293
LOGGER .error ("Request failed with status code: " + status );
269
294
throw new IOException ("Request failed with status code: " + status );
270
295
}
271
-
272
296
try {
273
297
HttpEntity respEntity = response .getEntity ();
274
298
ObjectMapper mapper = createJsonMapper ();
275
299
Boolean hasAccess = mapper .readValue (respEntity .getContent (), Boolean .class );
276
300
// release all resources held by httpentity
277
301
EntityUtils .consume (respEntity );
302
+ response .close ();
303
+ myClient .close ();
278
304
return hasAccess ;
279
305
} catch (Exception e ) {
280
306
LOGGER .error ("" , e );
281
307
throw new IOException (e );
282
308
} finally {
283
- response .close ();
309
+ try {
310
+ response .close ();
311
+ myClient .close ();
312
+ } catch (IOException e ) {
313
+ }
284
314
}
285
315
}
286
316
0 commit comments