Code Review
/
holmes
/
dsa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fixed a DMaaP Request Problem
[holmes/dsa.git]
/
dmaap-dsa
/
src
/
main
/
java
/
org
/
onap
/
holmes
/
dsa
/
dmaappolling
/
Subscriber.java
diff --git
a/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
b/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
index
e4276d4
..
b67fc8f
100644
(file)
--- a/
dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
+++ b/
dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
@@
-24,7
+24,10
@@
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.Getter;
import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
@@
-33,6
+36,7
@@
import org.onap.holmes.common.utils.HttpsUtils;
@Getter
@Setter
@Getter
@Setter
+@Slf4j
public class Subscriber {
private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
public class Subscriber {
private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
@@
-53,7
+57,7
@@
public class Subscriber {
* The number of milliseconds to poll interval time. This should normally be used, and set at
* 15000 or higher.
*/
* The number of milliseconds to poll interval time. This should normally be used, and set at
* 15000 or higher.
*/
- private int period =
15000
;
+ private int period =
timeout
;
private boolean secure;
private String topic;
private boolean secure;
private String topic;
@@
-80,12
+84,24
@@
public class Subscriber {
private List<String> getDMaaPData() throws Exception {
String response;
private List<String> getDMaaPData() throws Exception {
String response;
+ CloseableHttpClient closeableHttpClient = null;
+ HttpGet httpGet = new HttpGet(url + "/" + consumerGroup + "/" + consumer + "?timeout=" + period);
try {
try {
+ closeableHttpClient = HttpsUtils.getHttpClient(timeout);
HttpResponse httpResponse = HttpsUtils
HttpResponse httpResponse = HttpsUtils
- .get(
url + "/" + consumerGroup + "/" + consumer, new HashMap<>(), timeou
t);
+ .get(
httpGet, new HashMap<>(), closeableHttpClien
t);
response = HttpsUtils.extractResponseEntity(httpResponse);
} catch (Exception e) {
throw e;
response = HttpsUtils.extractResponseEntity(httpResponse);
} catch (Exception e) {
throw e;
+ } finally {
+ httpGet.releaseConnection();
+ if (closeableHttpClient != null) {
+ try {
+ closeableHttpClient.close();
+ } catch (IOException e) {
+ log.warn("Failed to close http client!");
+ }
+ }
}
return GsonUtil.jsonToBean(response, List.class);
}
}
return GsonUtil.jsonToBean(response, List.class);
}