[jboss-cvs] Picketbox SVN: r232 - 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:19:26 EDT 2011
Author: mmoyses
Date: 2011-07-06 14:19:25 -0400 (Wed, 06 Jul 2011)
New Revision: 232
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-04 17:17:25 UTC (rev 231)
+++ 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)
@@ -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: 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-04 17:17:25 UTC (rev 231)
+++ 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)
@@ -95,7 +95,8 @@
*/
public synchronized void addRole(Role role)
{
- this.roles.add(role);
+ if (!this.roles.contains(role))
+ this.roles.add(role);
}
/*
@@ -105,7 +106,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);
+ }
+ }
+ }
}
/*
More information about the jboss-cvs-commits
mailing list