aboutsummaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-04-28 13:29:21 -0400
committerDan Timoney <dtimoney@att.com>2017-04-28 13:29:21 -0400
commit221418795ed57830944d1dd43bcf0cadd1c9985b (patch)
treef1eb03539cb84158d9ebaff13d8eed44cb3eb0db /filters
parentfec3c1deb69712736d49415d88f2441d92f61cbb (diff)
[SONAR] Address blockers
Address blockers identified in Sonar scan Change-Id: I531dd501acc97b70a9f3fc9c40744836bbbaf718 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'filters')
-rw-r--r--filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java55
1 files changed, 11 insertions, 44 deletions
diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java
index 183301b..79559a4 100644
--- a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java
+++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -212,7 +212,7 @@ public class RequestResponseDbLoggingFilter implements Filter {
} finally {
- if (request != null && request instanceof HttpServletRequest) {
+ if (request instanceof HttpServletRequest) {
t1 = System.currentTimeMillis();
@@ -243,55 +243,22 @@ public class RequestResponseDbLoggingFilter implements Filter {
private String decompressGZIPByteArray(byte[] bytes) {
- BufferedReader in = null;
- InputStreamReader inR = null;
- ByteArrayInputStream byteS = null;
- GZIPInputStream gzS = null;
StringBuilder str = new StringBuilder();
- try {
- byteS = new ByteArrayInputStream(bytes);
- gzS = new GZIPInputStream(byteS);
- inR = new InputStreamReader(gzS);
- in = new BufferedReader(inR);
-
- if (in != null) {
+ try (ByteArrayInputStream byteS = new ByteArrayInputStream(bytes);
+ GZIPInputStream gzS = new GZIPInputStream(byteS);
+ InputStreamReader inR = new InputStreamReader(gzS);
+ BufferedReader in = new BufferedReader(inR);) {
- String content;
+ String content;
- while ((content = in.readLine()) != null) {
- str.append(content);
- }
+ while ((content = in.readLine()) != null) {
+ str.append(content);
}
} catch (Exception e) {
log.error("Failed get read GZIPInputStream", e);
- } finally {
-
- if (byteS != null)
- try {
- byteS.close();
- } catch (IOException e1) {
- log.error("Failed to close ByteStream", e1);
- }
- if (gzS != null)
- try {
- gzS.close();
- } catch (IOException e2) {
- log.error("Failed to close GZStream", e2);
- }
- if (inR != null)
- try {
- inR.close();
- } catch (IOException e3) {
- log.error("Failed to close InputReader", e3);
- }
- if (in != null)
- try {
- in.close();
- } catch (IOException e) {
- log.error("Failed to close BufferedReader", e);
- }
}
+
return str.toString();
}
}