>From f30a0339cdd12dd49af5b9e2e12a5c96a5968d4f Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 13 Apr 2015 02:00:10 -0400 Subject: [PATCH 33/33] Consolidate profile persistent search try/catch blocks --- .../cmscore/profile/LDAPProfileSubsystem.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java index cdb5a36a95e9cf25429b80b27686416d28a05632..1bf08dc8fffb3f5a6276a1b96ddc4503d10cf11a 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java +++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java @@ -277,7 +277,7 @@ public class LDAPProfileSubsystem LDAPPersistSearchControl persistCtrl = new LDAPPersistSearchControl(op, false, true, true); - LDAPConnection conn; + LDAPConnection conn = null; CMS.debug("Profile change monitor: starting."); @@ -285,16 +285,6 @@ public class LDAPProfileSubsystem forgetAllProfiles(); try { conn = dbFactory.getConn(); - } catch (ELdapException e) { - CMS.debug("Profile change monitor: failed to get LDAPConnection. Retrying in 1 second."); - try { - Thread.sleep(1000); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - } - continue; - } - try { LDAPSearchConstraints cons = conn.getSearchConstraints(); cons.setServerControls(persistCtrl); cons.setBatchSize(1); @@ -343,13 +333,23 @@ public class LDAPProfileSubsystem readProfile(entry); } } + } catch (ELdapException e) { + CMS.debug("Profile change monitor: failed to get LDAPConnection. Retrying in 1 second."); + try { + Thread.sleep(1000); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } } catch (LDAPException e) { CMS.debug("Profile change monitor: Caught exception: " + e.toString()); } finally { - try { - dbFactory.returnConn(conn); - } catch (Exception e) { - CMS.debug("Profile change monitor: Error releasing the LDAPConnection" + e.toString()); + if (conn != null) { + try { + dbFactory.returnConn(conn); + conn = null; + } catch (Exception e) { + CMS.debug("Profile change monitor: Error releasing the LDAPConnection" + e.toString()); + } } } } -- 2.1.0