Browse code

BM-15085 Fix: LDAP pool connexions release

Anthony Prades authored on 02/08/2019 13:14:20
Showing 1 changed files
... ...
@@ -92,8 +92,10 @@ public class ImportLdapAuthenticationService extends ImportAuthenticationService
92 92
 			throw re;
93 93
 		} catch (Exception e) {
94 94
 			logger.error("Fail to get LDAP DN for user: " + userLogin + "@" + domainName, e);
95
-			ldapConCtx.ifPresent(lcc -> releaseConnection(ldapPoolByDomain, parameters, lcc.setError()));
95
+			ldapConCtx.ifPresent(lcc -> lcc.setError());
96 96
 			return null;
97
+		} finally {
98
+			ldapConCtx.ifPresent(lcc -> releaseConnection(ldapPoolByDomain, parameters, lcc));
97 99
 		}
98 100
 
99 101
 		if (ldapUserLogin == null) {
... ...
@@ -133,8 +135,10 @@ public class ImportLdapAuthenticationService extends ImportAuthenticationService
133 135
 			throw re;
134 136
 		} catch (Exception e) {
135 137
 			logger.error(String.format("Error searching external ID %s", uuid), e);
136
-			ldapConCtx.ifPresent(lcc -> releaseConnection(ldapPoolByDomain, parameters, lcc.setError()));
138
+			ldapConCtx.ifPresent(lcc -> lcc.setError());
137 139
 			throw e;
140
+		} finally {
141
+			ldapConCtx.ifPresent(lcc -> releaseConnection(ldapPoolByDomain, parameters, lcc));
138 142
 		}
139 143
 
140 144
 		if (ldapUserLogin == null) {