[jboss-cvs] Picketbox SVN: r233 - branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 6 14:35:30 EDT 2011


Author: mmoyses
Date: 2011-07-06 14:35:30 -0400 (Wed, 06 Jul 2011)
New Revision: 233

Modified:
   branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java
   branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java
Log:
SECURITY-603: fixing SimpleRole memory leak

Modified: branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java
===================================================================
--- branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java	2011-07-06 18:19:25 UTC (rev 232)
+++ branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java	2011-07-06 18:35:30 UTC (rev 233)
@@ -103,20 +103,20 @@
    @Override
    public int hashCode()
    {
-	  int hashCode = roleName.hashCode();
-	  if (parent != null)
-		 hashCode += parent.hashCode();
-	  return hashCode;
+      int hashCode = roleName.hashCode();
+      if (parent != null)
+         hashCode += parent.hashCode();
+      return hashCode;
    }
 
    @Override
    public boolean equals(Object obj)
    {
-	  if (obj instanceof SimpleRole)
-	  {
-		 SimpleRole other = SimpleRole.class.cast(obj);
-		 return parent != null ? (roleName.equals(other.roleName) && parent.equals(other.parent)) : (roleName.equals(other.roleName) && other.parent == null);
-	  }
-	  return false;
+      if (obj instanceof SimpleRole)
+      {
+         SimpleRole other = SimpleRole.class.cast(obj);
+         return parent != null ? (roleName.equals(other.roleName) && parent.equals(other.parent)) : (roleName.equals(other.roleName) && other.parent == null);
+      }
+      return false;
    }
-}
\ No newline at end of file
+}

Modified: branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java
===================================================================
--- branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java	2011-07-06 18:19:25 UTC (rev 232)
+++ branches/Branch_3_x/security-jboss-sx/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java	2011-07-06 18:35:30 UTC (rev 233)
@@ -57,7 +57,7 @@
    public SimpleRoleGroup(String roleName, List<Role> roles)
    {
       super(roleName);
-      this.roles.addAll(roles);
+      addAll(roles);
    }
 
    public SimpleRoleGroup(Group rolesGroup)
@@ -66,7 +66,8 @@
       Enumeration<? extends Principal> principals = rolesGroup.members();
       while (principals.hasMoreElements())
       {
-         roles.add(new SimpleRole(principals.nextElement().getName()));
+         SimpleRole role = new SimpleRole(principals.nextElement().getName());
+         addRole(role);
       }
    }
 
@@ -75,7 +76,8 @@
       super(ROLES_IDENTIFIER);
       for (Principal p : rolesAsPrincipals)
       {
-         roles.add(new SimpleRole(p.getName()));
+         SimpleRole role = new SimpleRole(p.getName());
+         addRole(role);
       }
    }
 
@@ -95,8 +97,8 @@
     */
    public synchronized void addRole(Role role)
    {
-	  if (!this.roles.contains(role))
-		 this.roles.add(role);
+      if (!this.roles.contains(role))
+         this.roles.add(role);
    }
 
    /*
@@ -109,11 +111,11 @@
       {
          for (Role role : roles)
          {
-			if (!this.roles.contains(role))
-			{
-			   this.roles.add(role);
-			}
-		 }
+            if (!this.roles.contains(role))
+            {
+               this.roles.add(role);
+            }
+         }
       }
    }
 
@@ -248,4 +250,4 @@
       builder.append(")");
       return builder.toString();
    }
-}
\ No newline at end of file
+}



More information about the jboss-cvs-commits mailing list