summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-fw/src
diff options
context:
space:
mode:
authorKrishnajinka <kris.jinka@samsung.com>2018-07-16 17:27:59 +0900
committerKrishnajinka <kris.jinka@samsung.com>2018-07-16 17:28:37 +0900
commit39191aaa6cf9f9d164c995e580c7df418b59b5c9 (patch)
tree6c6b05033b1bd63a8d95be2dc2ed30f6bb16f852 /ecomp-sdk/epsdk-fw/src
parenta96a3e49cd472aa902c22143358b87562603d47c (diff)
FIX TO USE TRY WITH RESOURCES
FIX SONAR ISSUES RELATED WITH USE OF TRY WITH RESOURCES INSTEAD OF JUST TRY Issue-ID: PORTAL-336 Change-Id: I143c3d6167b101e5113faa3c70f57bfb8638e8de Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src')
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java30
1 files changed, 14 insertions, 16 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
index 8d797c37..1ce03146 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java
@@ -589,27 +589,25 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer
String body = null;
StringBuilder stringBuilder = new StringBuilder();
- BufferedReader bufferedReader = null;
- try {
- InputStream inputStream = request.getInputStream();
+
+ try(InputStream inputStream = request.getInputStream()) {
if (inputStream != null) {
- bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- char[] charBuffer = new char[1024];
- int bytesRead = -1;
- while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
- stringBuilder.append(charBuffer, 0, bytesRead);
+ try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));){
+ char[] charBuffer = new char[1024];
+ int bytesRead = -1;
+ while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
+ stringBuilder.append(charBuffer, 0, bytesRead);
+ }
+ } catch(IOException e) {
+ logger.error("readRequestBody", e);
+ throw e;
}
} else {
stringBuilder.append("");
}
- } finally {
- if (bufferedReader != null) {
- try {
- bufferedReader.close();
- } catch (IOException ex) {
- logger.error("readRequestBody", ex);
- }
- }
+ } catch(IOException e) {
+ logger.error("readRequestBody", e);
+ throw e;
}
body = stringBuilder.toString();
return body;