check if localsession object null before closing 89/30789/1
authorHavaldar Girish <hg0071052@techmahindra.com>
Thu, 8 Feb 2018 03:49:10 +0000 (09:19 +0530)
committerHavaldar Girish <hg0071052@techmahindra.com>
Thu, 8 Feb 2018 03:54:49 +0000 (09:24 +0530)
Before closing the session check if the localsession is not null
Sonar Link:
https://sonar.onap.org/component_issues/index?id=org.onap.portal%3Aonap-portal-parent#resolved=false|severities=BLOCKER
Location:
/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java
Line No-382

Change-Id: Id44800c1ab0ee03dd4920c756fb85b342dc1dd2a
Issue-ID: PORTAL-154
Signed-off-by: Havaldar Girish <hg0071052@techmahindra.com>
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java

index 3535f75..c65b4af 100644 (file)
@@ -371,7 +371,9 @@ public class UserRolesCommonServiceImpl  {
                                throw new Exception(e.getMessage());
                        }
                } finally {
-                       localSession.close();
+                       if (localSession != null) {
+                               localSession.close();           
+                       }                               
                        if (!result && !"DELETE".equals(reqType)) {
                                throw new Exception(
                                                "Exception occurred in syncUserRoles while closing database session for app: '" + appId + "'.");