Frank Kobzik has uploaded a new change for review.

Change subject: frontend: ConcurrentModificationException in AdElementListModel
......................................................................

frontend: ConcurrentModificationException in AdElementListModel

The exception occured in the populateRoles method when user is adding
permissions to the VM in permissions subtab. The problem is introduced by
refactoring in 05c06da3 and is only visible in gwt-debug console.

The problem was caused by removing items from the list in the for-each loop.
Fixed by introducing a copy of the modified list (to avoid modifying the
collection passed in the argument).

Change-Id: Id845725507782162c14f6e7b214f65cc6060f59b
Signed-off-by: Frantisek Kobzik <fkob...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/AdElementListModel.java
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/45/13345/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/AdElementListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/AdElementListModel.java
index 6545362..777a99a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/AdElementListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/users/AdElementListModel.java
@@ -198,11 +198,14 @@
 
     protected void populateRoles(List<Role> roles){
         Role selectedRole = null;
+        List<Role> rolesToPopulate = new ArrayList<Role>();
+
         for (Role role : roles) {
+
             if (role.getId() != null) {
              // ignore CONSUME_QUOTA_ROLE in UI
-                if 
(role.getId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
-                    roles.remove(role);
+                if 
(!role.getId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
+                    rolesToPopulate.add(role);
                 }
                 //select engine user if it exists
                 if (role.getId().equals(ApplicationGuids.engineUser.asGuid())) 
{
@@ -211,14 +214,14 @@
             }
         }
 
-        Collections.sort(roles, new Linq.RoleNameComparer());
+        Collections.sort(rolesToPopulate, new Linq.RoleNameComparer());
 
-        getRole().setItems(roles);
+        getRole().setItems(rolesToPopulate);
         if (selectedRole != null) {
             getRole().setSelectedItem(selectedRole);
-        } else if (roles.size() > 0){
+        } else if (rolesToPopulate.size() > 0){
             //if engine user does not exist, pick the first on the list
-            getRole().setSelectedItem(roles.get(0));
+            getRole().setSelectedItem(rolesToPopulate.get(0));
         }
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id845725507782162c14f6e7b214f65cc6060f59b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Frank Kobzik <fkob...@redhat.com>
Gerrit-Reviewer: Shireesh Anjal <san...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to