From: Havaldar Girish Date: Thu, 8 Feb 2018 03:49:10 +0000 (+0530) Subject: check if localsession object null before closing X-Git-Tag: v2.2.0~39^2~1 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=portal.git;a=commitdiff_plain;h=ed404fea2eae15505b42a15e35f762be3dfc74d9 check if localsession object null before closing 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 --- diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java index 3535f753..c65b4af9 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java @@ -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 + "'.");