diff --git a/sugoi-api-ldap-utils/src/main/java/fr/insee/sugoi/ldap/utils/LdapFactory.java b/sugoi-api-ldap-utils/src/main/java/fr/insee/sugoi/ldap/utils/LdapFactory.java index ea7e1cb0..d3b7fa11 100644 --- a/sugoi-api-ldap-utils/src/main/java/fr/insee/sugoi/ldap/utils/LdapFactory.java +++ b/sugoi-api-ldap-utils/src/main/java/fr/insee/sugoi/ldap/utils/LdapFactory.java @@ -57,13 +57,14 @@ public static LDAPConnectionPool getConnectionPool(Map config) if (openLdapPoolConnection.containsKey(name)) { openLdapPoolConnection.get(name).close(); } - openLdapPoolConnectionConfig.put(key, name); openLdapPoolConnection.put( name, new LDAPConnectionPool( new LDAPConnection( config.get(LdapConfigKeys.URL), Integer.valueOf(config.get(LdapConfigKeys.PORT))), Integer.valueOf(config.get(LdapConfigKeys.POOL_SIZE)))); + // Only put key if ldap connection correctly open + openLdapPoolConnectionConfig.put(key, name); } return openLdapPoolConnection.get(name); } @@ -89,11 +90,12 @@ public static LDAPConnection getSingleConnection(Map config, boo if (openLdapMonoConnection.containsKey(name) || forceErase) { openLdapMonoConnection.get(name).close(); } - openLdapMonoConnectionConfig.put(key, name); openLdapMonoConnection.put( name, new LDAPConnection( config.get(LdapConfigKeys.URL), Integer.valueOf(config.get(LdapConfigKeys.PORT)))); + // Only put key if ldap connection correctly open + openLdapMonoConnectionConfig.put(key, name); } return openLdapMonoConnection.get(name); } @@ -123,7 +125,6 @@ public static LDAPConnectionPool getConnectionPoolAuthenticated(Map