Hi All,

Found a bug in SubDomainAwareGroupManagementAgent.

Here's the scenario.


   - Assume that the back-end node Member (*M*) doesn't have a 'sub domain'
   property and then the 'subDomain' value will be *null*.
   - In ELB, say, there's a SubDomainAwareGroupManagementAgent for domain '*
   x*' and sub domain '*y*'.
   - According to the current code member '*M*' will get added to the
   SubDomainAwareGroupManagementAgent which represents a cluster having a sub
   domain '*y*'. Which is wrong IMO.

Hence, following is the fix I propose [1].

So, in brief, if a Member has not specified a sub domain property, it
should *considered* to be added to the matching cluster, if and only if the
SubDomainAwareGroupManagementAgent's sub domain is __$default (which is the
default sub domain.)

[1]

/**
  * This GroupManagementAgent can handle group membership based on cluster
sub-domains.
@@ -34,7 +35,8 @@
     @Override
     public void applicationMemberAdded(Member member) {
         String subDomain = member.getProperties().getProperty("subDomain");
-        if (subDomain == null || subDomain.equals(this.subDomain)) {
+        if ((subDomain == null &&
Constants.DEFAULT_SUB_DOMAIN.equals(this.subDomain)) ||
+            subDomain.equals(this.subDomain)) {
             super.applicationMemberAdded(member);
         }
     }
@@ -42,7 +44,8 @@
     @Override
     public void applicationMemberRemoved(Member member) {
         String subDomain = member.getProperties().getProperty("subDomain");
-        if (subDomain == null || subDomain.equals(this.subDomain)) {
+        if ((subDomain == null &&
Constants.DEFAULT_SUB_DOMAIN.equals(this.subDomain)) ||
+            subDomain.equals(this.subDomain)) {
             super.applicationMemberRemoved(member);
         }
     }


-- 

Thanks & regards,
Nirmal

Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/

<http://nirmalfdo.blogspot.com/>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to