[jboss-cvs] JBossAS SVN: r112577 - projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 16 11:42:43 EST 2012
Author: dehort
Date: 2012-01-16 11:42:43 -0500 (Mon, 16 Jan 2012)
New Revision: 112577
Modified:
projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java
projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java
Log:
Backporting a potential fix for a memory leak in SimpleRole
[JBPAPP-7935]
Modified: projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java
===================================================================
--- projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java 2012-01-16 16:18:00 UTC (rev 112576)
+++ projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRole.java 2012-01-16 16:42:43 UTC (rev 112577)
@@ -99,4 +99,24 @@
{
return roleName;
}
+
+ @Override
+ public int 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;
+ }
}
\ No newline at end of file
Modified: projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java
===================================================================
--- projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java 2012-01-16 16:18:00 UTC (rev 112576)
+++ projects/security/security-jboss-sx/branches/2.0.4.SP7_JBPAPP-7935/identity/src/main/java/org/jboss/security/identity/plugins/SimpleRoleGroup.java 2012-01-16 16:42:43 UTC (rev 112577)
@@ -59,7 +59,7 @@
super(roleName);
if (this.roles == null)
this.roles = new ArrayList<Role>();
- this.roles.addAll(roles);
+ addAll(roles);
}
public SimpleRoleGroup(Group rolesGroup)
@@ -68,7 +68,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);
}
}
@@ -77,7 +78,8 @@
super(ROLES_IDENTIFIER);
for (Principal p : rolesAsPrincipals)
{
- roles.add(new SimpleRole(p.getName()));
+ SimpleRole role = new SimpleRole(p.getName());
+ addRole(role);
}
}
@@ -97,7 +99,8 @@
*/
public synchronized void addRole(Role role)
{
- this.roles.add(role);
+ if (!this.roles.contains(role))
+ this.roles.add(role);
}
/*
@@ -107,7 +110,15 @@
public synchronized void addAll(List<Role> roles)
{
if (roles != null)
- this.roles.addAll(roles);
+ {
+ for (Role role : roles)
+ {
+ if (!this.roles.contains(role))
+ {
+ this.roles.add(role);
+ }
+ }
+ }
}
/*
@@ -238,4 +249,4 @@
builder.append(")");
return builder.toString();
}
-}
\ No newline at end of file
+}
More information about the jboss-cvs-commits
mailing list