summaryrefslogtreecommitdiffstats
path: root/ResmanagementService
diff options
context:
space:
mode:
authorKrishnajinka <kris.jinka@samsung.com>2018-07-20 14:35:25 +0900
committerKrishnajinka <kris.jinka@samsung.com>2018-07-20 14:36:24 +0900
commite3332f29723ffbdea6f20dacdc3743da23f81a79 (patch)
treea489e919ff835ce220ce15edfaffd07a3276af75 /ResmanagementService
parentd0df1a5bb59ce039a02baf2e51fd77a9e38a122a (diff)
FIX USING TRY WITH RESOURCES
ISSUE RAISED BY SONAR ABOUT CLOSING RESOURCES OPENED EFFICIENTLY USING TRY WITH RES CONSTRUCT Issue-ID: VFC-966 Change-Id: I11d0bf12300fe6b47dd8ac63d03d32864de41808 Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
Diffstat (limited to 'ResmanagementService')
-rw-r--r--ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/RestHttpContentExchange.java33
1 files changed, 4 insertions, 29 deletions
diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/RestHttpContentExchange.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/RestHttpContentExchange.java
index fa01516..0d8ec94 100644
--- a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/RestHttpContentExchange.java
+++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/common/util/restclient/RestHttpContentExchange.java
@@ -79,40 +79,15 @@ public class RestHttpContentExchange extends ContentExchange {
if(data == null) {
return "";
}
- ByteArrayInputStream input = null;
- GZIPInputStream gzis = null;
- InputStreamReader reader = null;
+
final StringBuilder out = new StringBuilder();
- try {
- input = new ByteArrayInputStream(data);
- gzis = new GZIPInputStream(input);
- reader = new InputStreamReader(gzis, Charset.forName(RestfulClientConst.ENCODING));
+ try(ByteArrayInputStream input = new ByteArrayInputStream(data);
+ GZIPInputStream gzis = new GZIPInputStream(input);
+ InputStreamReader reader = new InputStreamReader(gzis, Charset.forName(RestfulClientConst.ENCODING))) {
final char[] buff = new char[1024];
for(int n; (n = reader.read(buff)) != -1;) {
out.append(new String(buff, 0, n));
}
- } finally {
- if(reader != null) {
- try {
- reader.close();
- } catch(final IOException e) {
- LOGGER.error("decompress Gzip reader exception:", e);
- }
- }
- if(gzis != null) {
- try {
- gzis.close();
- } catch(final IOException e) {
- LOGGER.error("decompress Gzip exception:", e);
- }
- }
- if(input != null) {
- try {
- input.close();
- } catch(final IOException e) {
- LOGGER.error("decompress Gzip input exception:", e);
- }
- }
}
return out.toString();