Skip to content
Snippets Groups Projects
Commit 12fa9c52 authored by Brian Major's avatar Brian Major
Browse files

s1651 - Fixed memory leak by closing userDAO connections

parent 9d7c2c0b
No related branches found
No related tags found
No related merge requests found
......@@ -68,18 +68,19 @@
*/
package ca.nrc.cadc.ac.server.ldap;
import java.security.AccessControlException;
import java.security.Principal;
import java.util.Collection;
import org.apache.log4j.Logger;
import ca.nrc.cadc.ac.Group;
import ca.nrc.cadc.ac.GroupAlreadyExistsException;
import ca.nrc.cadc.ac.GroupNotFoundException;
import ca.nrc.cadc.ac.IdentityType;
import ca.nrc.cadc.ac.Role;
import ca.nrc.cadc.ac.UserNotFoundException;
import ca.nrc.cadc.ac.server.GroupPersistence;
import ca.nrc.cadc.net.TransientException;
import java.security.AccessControlException;
import java.security.Principal;
import java.util.Collection;
import org.apache.log4j.Logger;
public class LdapGroupPersistence<T extends Principal>
implements GroupPersistence<T>
......@@ -98,9 +99,11 @@ public class LdapGroupPersistence<T extends Principal>
AccessControlException
{
LdapGroupDAO<T> groupDAO = null;
LdapUserDAO<T> userDAO = null;
try
{
groupDAO = new LdapGroupDAO<T>(config, new LdapUserDAO<T>(config));
userDAO = new LdapUserDAO<T>(config);
groupDAO = new LdapGroupDAO<T>(config, userDAO);
Group ret = groupDAO.getGroup(groupName);
return ret;
}
......@@ -110,6 +113,10 @@ public class LdapGroupPersistence<T extends Principal>
{
groupDAO.close();
}
if (userDAO != null)
{
userDAO.close();
}
}
}
......@@ -118,9 +125,11 @@ public class LdapGroupPersistence<T extends Principal>
AccessControlException, UserNotFoundException
{
LdapGroupDAO<T> groupDAO = null;
LdapUserDAO<T> userDAO = null;
try
{
groupDAO = new LdapGroupDAO<T>(config, new LdapUserDAO<T>(config));
userDAO = new LdapUserDAO<T>(config);
groupDAO = new LdapGroupDAO<T>(config, userDAO);
Group ret = groupDAO.addGroup(group);
return ret;
}
......@@ -130,6 +139,10 @@ public class LdapGroupPersistence<T extends Principal>
{
groupDAO.close();
}
if (userDAO != null)
{
userDAO.close();
}
}
}
......@@ -138,9 +151,11 @@ public class LdapGroupPersistence<T extends Principal>
AccessControlException
{
LdapGroupDAO<T> groupDAO = null;
LdapUserDAO<T> userDAO = null;
try
{
groupDAO = new LdapGroupDAO<T>(config, new LdapUserDAO<T>(config));
userDAO = new LdapUserDAO<T>(config);
groupDAO = new LdapGroupDAO<T>(config, userDAO);
groupDAO.deleteGroup(groupName);
}
finally
......@@ -149,6 +164,10 @@ public class LdapGroupPersistence<T extends Principal>
{
groupDAO.close();
}
if (userDAO != null)
{
userDAO.close();
}
}
}
......@@ -157,9 +176,11 @@ public class LdapGroupPersistence<T extends Principal>
AccessControlException, UserNotFoundException
{
LdapGroupDAO<T> groupDAO = null;
LdapUserDAO<T> userDAO = null;
try
{
groupDAO = new LdapGroupDAO<T>(config, new LdapUserDAO<T>(config));
userDAO = new LdapUserDAO<T>(config);
groupDAO = new LdapGroupDAO<T>(config, userDAO);
Group ret = groupDAO.modifyGroup(group);
return ret;
}
......@@ -169,6 +190,10 @@ public class LdapGroupPersistence<T extends Principal>
{
groupDAO.close();
}
if (userDAO != null)
{
userDAO.close();
}
}
}
......@@ -177,9 +202,11 @@ public class LdapGroupPersistence<T extends Principal>
TransientException, AccessControlException
{
LdapGroupDAO<T> groupDAO = null;
LdapUserDAO<T> userDAO = null;
try
{
groupDAO = new LdapGroupDAO<T>(config, new LdapUserDAO<T>(config));
userDAO = new LdapUserDAO<T>(config);
groupDAO = new LdapGroupDAO<T>(config, userDAO);
Collection<Group> ret = groupDAO.getGroups(userID, role, groupID);
return ret;
}
......@@ -189,6 +216,10 @@ public class LdapGroupPersistence<T extends Principal>
{
groupDAO.close();
}
if (userDAO != null)
{
userDAO.close();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment