Uploaded image for project: 'OpenAM'
  1. OpenAM
  2. OPENAM-985

LDAPv3Repo and associated classes can cause leak in the shutdown manager due to LDAP exceptions

    XMLWordPrintable

    Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Express8, Snapshot9, Snapshot9.5, Snapshot9.5.1, Snapshot9.5.2_RC1, Snapshot9.5.2, 9.5.3_RC1, 9.5.3, 9.5.4_RC1
    • 9.5.5, 10.0.0
    • ldapjdk
    • Rank:
      1|hzn6uv:

      Description

      If there is a LDAPException then the LDAP sub system can re-initialise itself. But this leaves a reference to itself in the shutdown manager. When the LDAPv3Repo is shutdown, it should remove itself from the shutdown manager.

      Index: com/sun/identity/idm/plugins/ldapv3/LDAPv3Repo.java
      ===================================================================
      — com/sun/identity/idm/plugins/ldapv3/LDAPv3Repo.java (revision 1393)
      +++ com/sun/identity/idm/plugins/ldapv3/LDAPv3Repo.java (working copy)
      @@ -270,6 +270,9 @@

      LDAPPersistSearchControl.DELETE
      LDAPPersistSearchControl.MODDN;

      + private ShutdownListener shutdownListener = null;
      + private LDAPRebind reBind = null;
      +
      // access to the _eventsMgr and _eventsMgr needs to be sync.
      protected static Hashtable _eventsMgr = new Hashtable();

      @@ -784,16 +787,17 @@
      ldc.getAuthenticationDN(),
      ldc.getAuthenticationPassword(),
      ldc, connOptions);

      • shutdownMan.addShutdownListener(
      • new ShutdownListener() {
      • public void shutdown() {
      • hasShutdown = true;
      • if (connPool != null) { - connPool.destroy(); - }

        +
        + // create the shutdown hook
        + shutdownListener = new ShutdownListener() {
        + public void shutdown()

        Unknown macro: {+ if (connPool != null) { + connPool.destroy(); } }
      • );
        + };
        + // Register the shutdown hook
        + shutdownMan.addShutdownListener(shutdownListener);
        } finally { shutdownMan.releaseLockAndNotify(); }

        @@ -830,7 +834,8 @@

      protected void setDefaultReferralCredentials(LDAPConnection conn) {
      final LDAPConnection mConn = conn;

      • LDAPRebind reBind = new LDAPRebind() {
        +
        + reBind = new LDAPRebind() {
        public LDAPRebindAuth getRebindAuthentication(String host, int port) { return new LDAPRebindAuth(mConn.getAuthenticationDN(), mConn @@ -1076,14 +1081,37 @@ }

      + @Override
      public void shutdown() {

      • debug.message("LDAPv3Repo: shutdown");
        + if (debug.messageEnabled()) { + debug.message("LDAPv3Repo: shutdown"); + }

        hasShutdown = true;
        super.shutdown();
        if (connPool != null)

        { connPool.destroy(); + connPool = null; }

        +
        removeListener();
        +
        + if (shutdownListener != null) {
        + ShutdownManager shutdownMan = ShutdownManager.getInstance();
        + if (shutdownMan.acquireValidLock()) {
        + try

        Unknown macro: {+ shutdownMan.removeShutdownListener(shutdownListener);+ shutdownListener = null; + if (debug.messageEnabled()) { + debug.message("LDAPv3Repo: removed shutdown listener"); + }+ }

        finally

        { + shutdownMan.releaseLockAndNotify(); + }

        + }
        + }
        +
        + reBind = null;
        + myListener = null;
        }

      /*
      Index: com/sun/identity/idm/server/IdRepoPluginsCache.java
      ===================================================================
      — com/sun/identity/idm/server/IdRepoPluginsCache.java (revision 1393)
      +++ com/sun/identity/idm/server/IdRepoPluginsCache.java (working copy)
      @@ -698,6 +698,7 @@
      if (plugin != null)

      { plugin.removeListener(); plugin.shutdown(); + plugin = null; }

      if (idrepos != null && !idrepos.isEmpty())

      { // Iterate through the plugins @@ -709,6 +710,7 @@ repo.removeListener(); repo.shutdown(); }

      + idrepos = null;
      }
      }
      }

        Attachments

          Activity

            People

            sachiko Sachiko Wallace
            steve Steve Ferris
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: