Yair Zaslavsky has uploaded a new change for review.

Change subject: core: Fixing NPE in case a directory was not found for user.
......................................................................

core: Fixing NPE in case a directory was not found for user.

This can happen if the domain was removed by engine-manage-domains
(the users for the directory are not removed)

Change-Id: Ief4761b9234f3839a1dba1eefbf871ae2bae3c69
Signed-off-by: Yair Zaslavsky <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DbUserCacheManager.java
1 file changed, 13 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/25921/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DbUserCacheManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DbUserCacheManager.java
index bea4289..5299d8a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DbUserCacheManager.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/DbUserCacheManager.java
@@ -8,6 +8,7 @@
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.aaa.AuthenticationProfile;
 import org.ovirt.engine.core.aaa.AuthenticationProfileRepository;
 import org.ovirt.engine.core.aaa.Directory;
 import org.ovirt.engine.core.aaa.DirectoryGroup;
@@ -81,7 +82,18 @@
         Map<Directory, List<DbUser>> index = new HashMap<>();
 
         for (DbUser dbUser : dbUsers) {
-            Directory key = 
AuthenticationProfileRepository.getInstance().getProfile(dbUser.getDomain()).getDirectory();
+            AuthenticationProfile profile = 
AuthenticationProfileRepository.getInstance().getProfile(dbUser.getDomain());
+            if (profile == null) {
+                log.error(String.format("No profile was found for user %1$s. 
It is possible that the relevant domain for the user was removed for the user. 
Marking the user as inactive",
+                        dbUser.getLoginName()));
+                if (dbUser.isActive()) {
+                    dbUser.setActive(false);
+                    dao.update(dbUser);
+                }
+                continue;
+
+            }
+            Directory key = profile.getDirectory();
             List<DbUser> value = index.get(key);
             if (value == null) {
                 value = new ArrayList<DbUser>();


-- 
To view, visit http://gerrit.ovirt.org/25921
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief4761b9234f3839a1dba1eefbf871ae2bae3c69
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to