You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/03/05 12:37:00 UTC

git commit: updated refs/heads/master to 04bda84

Repository: cloudstack
Updated Branches:
  refs/heads/master 6fef3ed22 -> 04bda8429


Fixed coverity reported resource leak in LdapManagerImpl


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/04bda842
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/04bda842
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/04bda842

Branch: refs/heads/master
Commit: 04bda842995bc126760992199481a2bba6f38be4
Parents: 6fef3ed
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Thu Mar 5 16:54:47 2015 +0530
Committer: Rajani Karuturi <ra...@gmail.com>
Committed: Thu Mar 5 17:05:25 2015 +0530

----------------------------------------------------------------------
 .../ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04bda842/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
index 87c0443..dfd39a3 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java
@@ -74,9 +74,10 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
     public LdapConfigurationResponse addConfiguration(final String hostname, final int port) throws InvalidParameterValueException {
         LdapConfigurationVO configuration = _ldapConfigurationDao.findByHostname(hostname);
         if (configuration == null) {
+            LdapContext context = null;
             try {
                 final String providerUrl = "ldap://" + hostname + ":" + port;
-                _ldapContextFactory.createBindContext(providerUrl);
+                context = _ldapContextFactory.createBindContext(providerUrl);
                 configuration = new LdapConfigurationVO(hostname, port);
                 _ldapConfigurationDao.persist(configuration);
                 s_logger.info("Added new ldap server with hostname: " + hostname);
@@ -84,6 +85,8 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
             } catch (NamingException | IOException e) {
                 s_logger.debug("NamingException while doing an LDAP bind", e);
                 throw new InvalidParameterValueException("Unable to bind to the given LDAP server");
+            } finally {
+                closeContext(context);
             }
         } else {
             throw new InvalidParameterValueException("Duplicate configuration");