Author: bdaw
Date: 2007-07-10 07:50:52 -0400 (Tue, 10 Jul 2007)
New Revision: 7703
Modified:
branches/JBoss_Portal_Branch_2_6/identity/build.xml
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java
Log:
JBPORTAL-1545 - HibernateUserModuleImpl.removeUser potential unwanted NPE
Modified: branches/JBoss_Portal_Branch_2_6/identity/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/identity/build.xml 2007-07-10 11:36:14 UTC (rev
7702)
+++ branches/JBoss_Portal_Branch_2_6/identity/build.xml 2007-07-10 11:50:52 UTC (rev
7703)
@@ -480,11 +480,11 @@
<x-test>
- <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>-->
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPIdentityTestCase"/>-->
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>-->
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>-->
- <test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>-->
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPStaticRoleMembershipModuleTestCase"/>-->
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPUserProfileModuleTestCase"/>-->
<!--<test todir="${test.reports}"
name="org.jboss.portal.test.identity.ldap.LDAPExtUserModuleTestCase"/>
Modified:
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java 2007-07-10
11:36:14 UTC (rev 7702)
+++
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java 2007-07-10
11:50:52 UTC (rev 7703)
@@ -187,6 +187,11 @@
public void removeUser(Object id) throws IdentityException
{
+ if (id == null)
+ {
+ throw new IllegalArgumentException("User id cannot be null");
+ }
+
if (id instanceof Long)
{
try
@@ -194,11 +199,14 @@
Session session = getCurrentSession();
HibernateUserImpl user =
(HibernateUserImpl)session.load(HibernateUserImpl.class, (Serializable)id);
- String userName = user.getUserName();
+
if (user == null)
{
throw new NoSuchUserException("No such user " + id);
}
+
+ String userName = user.getUserName();
+
session.delete(user);
session.flush();
Modified:
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java 2007-07-10
11:36:14 UTC (rev 7702)
+++
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/test/identity/IdentityTest.java 2007-07-10
11:50:52 UTC (rev 7703)
@@ -9,6 +9,7 @@
import org.jboss.portal.identity.Role;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.ProfileMap;
+import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.common.p3p.P3PConstants;
@@ -315,6 +316,20 @@
assertNotNull(g2);
Assert.assertEquals("role2", g2.getName());
ctx.commit();
+
+ ctx.begin();
+
+ try
+ {
+ userModule.removeUser(new Long(9999999));
+ fail();
+ }
+ catch (IdentityException e)
+ {
+ //expected
+ }
+
+ ctx.commit();
}
public void testFindRoles() throws Exception
Show replies by date