Skip to content

Commit

Permalink
[FIX] Avoid null Ldap Connection
Browse files Browse the repository at this point in the history
Signed-off-by: Clément Dufaure <[email protected]>
  • Loading branch information
clement-dufaure committed Aug 12, 2021
1 parent 3e34f36 commit 9ba0fe0
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ public static LDAPConnectionPool getConnectionPool(Map<String, String> 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);
}
Expand All @@ -89,11 +90,12 @@ public static LDAPConnection getSingleConnection(Map<String, String> 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);
}
Expand Down Expand Up @@ -123,7 +125,6 @@ public static LDAPConnectionPool getConnectionPoolAuthenticated(Map<String, Stri
if (openLdapPoolConnection.containsKey(name)) {
openLdapPoolConnection.get(name).close();
}
openLdapPoolConnectionConfig.put(key, name);
openLdapPoolConnection.put(
name,
new LDAPConnectionPool(
Expand All @@ -133,6 +134,8 @@ public static LDAPConnectionPool getConnectionPoolAuthenticated(Map<String, Stri
config.get(LdapConfigKeys.USERNAME),
config.get(LdapConfigKeys.PASSWORD)),
Integer.valueOf(config.get(LdapConfigKeys.POOL_SIZE))));
// Only put key if ldap connection correctly open
openLdapPoolConnectionConfig.put(key, name);
}
return openLdapPoolConnection.get(name);
}
Expand All @@ -152,14 +155,15 @@ public static LDAPConnection getSingleConnectionAuthenticated(Map<String, String
if (openLdapMonoConnection.containsKey(name)) {
openLdapMonoConnection.get(name).close();
}
openLdapMonoConnectionConfig.put(key, name);
openLdapMonoConnection.put(
name,
new LDAPConnection(
config.get(LdapConfigKeys.URL),
Integer.valueOf(config.get(LdapConfigKeys.PORT)),
config.get(LdapConfigKeys.USERNAME),
config.get(LdapConfigKeys.PASSWORD)));
// Only put key if ldap connection correctly open
openLdapMonoConnectionConfig.put(key, name);
}
return openLdapMonoConnection.get(name);
}
Expand Down

0 comments on commit 9ba0fe0

Please sign in to comment.