directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r389299 - /directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
Date Mon, 27 Mar 2006 21:55:29 GMT
Author: elecharny
Date: Mon Mar 27 13:55:27 2006
New Revision: 389299

URL: http://svn.apache.org/viewcvs?rev=389299&view=rev
Log:
Fixed a memory consumption in LdapProtocolProvider : we where 
construction the encoder/decoder for each request...

Modified:
    directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java

Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?rev=389299&r1=389298&r2=389299&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
(original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
Mon Mar 27 13:55:27 2006
@@ -340,7 +340,11 @@
     private static final class ProtocolCodecFactoryImpl implements ProtocolCodecFactory
     {
         final Hashtable env;
-
+        
+        // Define two static members to avoid useless object constructions
+        static Asn1CodecEncoder encoder;
+        
+        static Asn1CodecDecoder decoder;
 
         public ProtocolCodecFactoryImpl()
         {
@@ -354,15 +358,25 @@
         }
 
 
-        public ProtocolEncoder getEncoder()
+        public synchronized ProtocolEncoder getEncoder()
         {
-            return new Asn1CodecEncoder( new MessageEncoder( env ) );
+        	if ( encoder == null )
+        	{
+        		encoder = new Asn1CodecEncoder( new MessageEncoder( env ) );
+        	}
+        	
+            return encoder;
         }
 
 
-        public ProtocolDecoder getDecoder()
+        public synchronized ProtocolDecoder getDecoder()
         {
-            return new Asn1CodecDecoder( new MessageDecoder( env ) );
+        	if ( decoder == null )
+        	{
+        		decoder = new Asn1CodecDecoder( new MessageDecoder( env ) );
+        	}
+        	
+            return decoder;
         }
     }
 



Mime
View raw message