You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/05/25 23:41:50 UTC

[GitHub] [qpid-broker-j] alex-rufous commented on a change in pull request #88: QPID:8525:[Broker-J]Fixed child deletion issue in group providers

alex-rufous commented on a change in pull request #88:
URL: https://github.com/apache/qpid-broker-j/pull/88#discussion_r639285379



##########
File path: broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java
##########
@@ -359,16 +364,21 @@ protected void onOpen()
             if (childClass == GroupMember.class)
             {
                 String memberName = (String) attributes.get(GroupMember.NAME);
-
-                _groupDatabase.addUserToGroup(memberName, getName());
-                UUID id = UUID.randomUUID();
-                Map<String,Object> attrMap = new HashMap<String, Object>();
-                attrMap.put(GroupMember.ID,id);
-                attrMap.put(GroupMember.NAME, memberName);
-                GroupMemberAdapter groupMemberAdapter = new GroupMemberAdapter(attrMap);
-                groupMemberAdapter.create();
-                return Futures.immediateFuture((C) groupMemberAdapter);
-
+                Set<String> users = _groupDatabase.getUsersInGroup(getName());
+                if(!users.contains(memberName))

Review comment:
       If a group provider is configured with caseSensitive==false, the user lookup should be case insensitive. It seems we can perform the user existence check directly in `Database#addUserToGroup(String, String)`. Thus, let's move the check there, andm throw `IllegalConfigurationException` from implementation of `Database#addUserToGroup(String, String)`. 
   
   

##########
File path: broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java
##########
@@ -205,17 +205,22 @@ public String getPath()
             {
                 throw new IllegalConfigurationException(String.format("Group provider '%s' is not activated. Cannot create a group.", getName()));
             }
+            Set<String> availableGroups = _groupDatabase.getAllGroups();
+            if(!availableGroups.contains(groupName))
+            {
+                _groupDatabase.createGroup(groupName);
 
-            _groupDatabase.createGroup(groupName);
-
-            Map<String,Object> attrMap = new HashMap<String, Object>();
-            UUID id = UUID.randomUUID();
-            attrMap.put(ConfiguredObject.ID, id);
-            attrMap.put(ConfiguredObject.NAME, groupName);
-            GroupAdapter groupAdapter = new GroupAdapter(attrMap);
-            groupAdapter.create();
-            return Futures.immediateFuture((C) groupAdapter);
-
+                Map<String, Object> attrMap = new HashMap<String, Object>();
+                UUID id = UUID.randomUUID();
+                attrMap.put(ConfiguredObject.ID, id);
+                attrMap.put(ConfiguredObject.NAME, groupName);
+                GroupAdapter groupAdapter = new GroupAdapter(attrMap);
+                groupAdapter.create();
+                return Futures.immediateFuture((C) groupAdapter);
+            }
+            else{

Review comment:
       The formatting does not follow Qpid code style

##########
File path: broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderImpl.java
##########
@@ -205,17 +205,22 @@ public String getPath()
             {
                 throw new IllegalConfigurationException(String.format("Group provider '%s' is not activated. Cannot create a group.", getName()));
             }
+            Set<String> availableGroups = _groupDatabase.getAllGroups();
+            if(!availableGroups.contains(groupName))

Review comment:
       If a group provider is configured with `caseSensitive==false`, the group lookup should be case insensitive. I would like to suggest to move group existence check into `Database#createGroup(String)` as database implementation already has a code to perform case insensitive group lookup. If group exists, an implementation of `Database#createGroup(String)` can throw `IllegalConfigurationException`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org