From 05d4affb7296e157581880544fd0fb49b9d98325 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 22 Sep 2011 15:51:27 +0000
Subject: [PATCH] Fix OPENDJ-293: InternalClientConnection memory leak when performing password modify/state extended operations or SASL binds

---
 opends/src/server/org/opends/server/protocols/internal/InternalClientConnection.java |   37 ++++++++++++++++---------------------
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/opends/src/server/org/opends/server/protocols/internal/InternalClientConnection.java b/opends/src/server/org/opends/server/protocols/internal/InternalClientConnection.java
index 35d6ff4..65c9057 100644
--- a/opends/src/server/org/opends/server/protocols/internal/InternalClientConnection.java
+++ b/opends/src/server/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2006-2009 Sun Microsystems, Inc.
+ *      Portions copyright 2011 ForgeRock AS
  */
 package org.opends.server.protocols.internal;
 
@@ -99,9 +100,6 @@
   // The static connection for root-based connections.
   private static InternalClientConnection rootConnection;
 
-  // The authentication info for this connection.
-  private AuthenticationInfo authenticationInfo;
-
   // The empty operation list for this connection.
   private LinkedList<Operation> operationList;
 
@@ -236,11 +234,23 @@
   {
     super();
 
-
     this.setNetworkGroup(NetworkGroup.getInternalNetworkGroup());
 
-    this.authenticationInfo = authInfo;
-    super.setAuthenticationInfo(authInfo);
+    // Don't call super.setAuthenticationInfo() since this will register this
+    // connection in the authenticated users table, which is unnecessary and
+    // will also cause the connection to be leaked since internal connections
+    // are never closed/disconnected.
+    if (authInfo == null)
+    {
+      this.authenticationInfo = new AuthenticationInfo();
+      updatePrivileges(null, false);
+    }
+    else
+    {
+      this.authenticationInfo = authInfo;
+      updatePrivileges(authInfo.getAuthorizationEntry(), authInfo.isRoot());
+    }
+
     super.setSizeLimit(0);
     super.setTimeLimit(0);
     super.setIdleTimeLimit(0);
@@ -655,21 +665,6 @@
 
 
   /**
-   * Retrieves information about the authentication that has been
-   * performed for this connection.
-   *
-   * @return  Information about the user that is currently
-   *          authenticated on this connection.
-   */
-  @Override()
-  public AuthenticationInfo getAuthenticationInfo()
-  {
-    return authenticationInfo;
-  }
-
-
-
-  /**
    * This method has no effect, as the authentication info for
    * internal client connections is set when the connection is created
    * and cannot be changed after the fact.

--
Gitblit v1.10.0