Skip to content

Commit

Permalink
[BUG] 🥅 Catch all LdapException when using mono connection
Browse files Browse the repository at this point in the history
Signed-off-by: Cécile Chemin <[email protected]>
  • Loading branch information
CChemin committed Dec 7, 2023
1 parent e46d688 commit e951513
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,18 @@ private <R extends SugoiObject> PageResult<R> searchOnLdap(
try {
searchResult = ldapMonoConnection.search(searchRequest);
} catch (LDAPException e) {
if (e.getResultCode().intValue() == ResultCode.SERVER_DOWN_INT_VALUE) {
try {
if (Boolean.TRUE.equals(
Boolean.valueOf(config.get(LdapConfigKeys.READ_CONNECTION_AUTHENTICATED)))) {
ldapMonoConnection = LdapFactory.getSingleConnectionAuthenticated(config, true);
} else {
ldapMonoConnection = LdapFactory.getSingleConnection(config, true);
}
} catch (LDAPException e1) {
throw new StoreException("Search failed", e1);
try {
logger.info("Retry connection for error code " + e.getResultCode().intValue());
if (Boolean.TRUE.equals(
Boolean.valueOf(config.get(LdapConfigKeys.READ_CONNECTION_AUTHENTICATED)))) {
ldapMonoConnection = LdapFactory.getSingleConnectionAuthenticated(config, true);
} else {
ldapMonoConnection = LdapFactory.getSingleConnection(config, true);
}
searchResult = ldapMonoConnection.search(searchRequest);
} else {
throw new StoreException("search failed", e);
} catch (LDAPException e1) {
throw new StoreException("Failed to reopen connection", e1);
}
searchResult = ldapMonoConnection.search(searchRequest);
}
PageResult<R> pageResult = new PageResult<>();
pageResult.setResults(
Expand Down

0 comments on commit e951513

Please sign in to comment.