forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGdcSardine.java
More file actions
38 lines (32 loc) · 1.13 KB
/
Copy pathGdcSardine.java
File metadata and controls
38 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright (C) 2004-2017, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.gdc;
import static com.gooddata.util.Validate.notNull;
import com.github.sardine.impl.SardineImpl;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.HttpClientBuilder;
import java.io.IOException;
/**
* This class extends SardineImpl, connections were not correctly closed by parent
*/
class GdcSardine extends SardineImpl {
public GdcSardine(HttpClientBuilder builder) {
super(builder);
}
/**
* had to be overriden, because parent method did not close connection after execution
*/
@Override
protected <T> T execute(HttpRequestBase request, ResponseHandler<T> responseHandler) throws IOException {
notNull(request,"request");
try {
return super.execute(request, responseHandler);
} finally {
request.releaseConnection();
}
}
}