Fix possible null pointer in sessions dao
@@ -262,10 +262,16 @@ public class UserSessionDAOImpl implements UserSessionDAO {
for (UserSession userSession : userSessionsList) {
for (Application app : userSession.getApplications()) {
Application appFromMap = applicationMap.get(app.getAppId());
+ if (appFromMap != null) {
app.setAppName(appFromMap.getAppName());
app.setResourceId(appFromMap.getResourceId());
}
}
+
+ // If application is not present in the SP_APP table but has a session associated with it,
+ // that application should not be considered for the session object.
+ userSession.getApplications().removeIf(application -> application.getAppName() == null);
+ }
}
} catch (DataAccessException e) {
throw new UserSessionException(String.format("Error while retrieving sessions from the database for the " +
