JUnits for coverage
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / service / UserServiceImpl.java
index 755de79..0f91f62 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START==========================================
  * ONAP Portal
  * ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
@@ -130,7 +130,9 @@ public class UserServiceImpl implements UserService {
                                logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId failed", e);
                        } finally {
                                try {
+                                       if(in!=null) {
                                        in.close();
+                                       }
                                        con.disconnect();
                                } catch (IOException e) {
                                        logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId failed to close", e);
@@ -187,8 +189,9 @@ public class UserServiceImpl implements UserService {
 
                                in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
                                String inputLine;
-                               while ((inputLine = in.readLine()) != null)
+                               while ((inputLine = in.readLine()) != null) {
                                        response.append(inputLine);
+                               }
                                JSONObject jObject = new JSONObject(response.toString()); // json
                                JSONArray jsonUsers = jObject.getJSONArray("response"); // get
                                                                                                                                                // data
@@ -224,8 +227,10 @@ public class UserServiceImpl implements UserService {
                                logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed", e);
                        } finally {
                                try {
+                                       if(in!=null) {
                                        in.close();
                                        con.disconnect();
+                                       }
                                } catch (IOException e) {
                                        logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed to close", e);
                                }