Răsfoiți Sursa

Fix for #155588 : don't leak connections from the ldap connection pool

David Boreham 20 ani în urmă
părinte
comite
2e23e027f6

+ 4 - 20
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/BatchProcessor.java

@@ -137,23 +137,10 @@ public class BatchProcessor {
         
         
     }
-    
-    protected void finalize() {
-        try { ldap_pool.shutdown(); }
-        catch (Exception e) {  }
-    }
-    
+
     void process(int index) {
-        netscape.ldap.LDAPConnection  ldc = null;
-        
-        ldc = ldap_pool.getConnection("");
-        
-        if (ldc == null) {
-            requests.set(index,null);
-        }
-        else {
-            
-           /* This is a hack:
+    	
+            /* This is a hack:
             * This code is required because of Axis' incomplete
             * implementation. Without these, whenever getNodeValue() and friends are
             * called, exceptions are deliberately thrown. When Axis is fully
@@ -175,7 +162,6 @@ public class BatchProcessor {
             Node res = null;
             if (proxyAuth != null)
                 context.setConstraints( proxyAuth);
-            context.setLdapConnection(ldc);
             context.setRootNode(myRequest.cloneNode(true));
             
             logger.log(Level.INFO, "Processing: starting {0}", RequestType);
@@ -236,9 +222,7 @@ public class BatchProcessor {
             requests.set(index,res);
             logger.log(Level.INFO, "Processing: finished {0}", RequestType);
             FirstRequest = false;
-            
-            ldap_pool.releaseConnection("",  ldc);
-        }
+            ldap_pool.releaseConnection( context.getLdapConnection() );
     }
     
     

+ 1 - 1
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/ProxyConnectionManager.java

@@ -205,7 +205,7 @@ class ProxyConnectionManager implements IConnectionManager {
             return;
         
         // reset the original constraints
-        conn.setSearchConstraints(_defaultSearchConstraints);
+        //conn.setSearchConstraints(_defaultSearchConstraints);
         
         // A soft close on the connection.
         // Returns the connection to the pool and make it available.

+ 5 - 0
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/gatewayHandler.java

@@ -89,6 +89,11 @@ public class gatewayHandler  extends BasicHandler {
         super.cleanup();
     }
 
+        
+    protected void finalize() {
+        new ProxyConnMgrFactory().getInstance().shutdown();
+    }
+    
 	 
     public boolean handleRequest(MessageContext context) {
     /*