directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r983657 - in /directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api: LdapNetworkConnection.java protocol/LdapProtocolCodecFactory.java protocol/LdapProtocolEncoder.java
Date Mon, 09 Aug 2010 14:30:15 GMT
Author: elecharny
Date: Mon Aug  9 14:30:14 2010
New Revision: 983657

URL: http://svn.apache.org/viewvc?rev=983657&view=rev
Log:
Fixed a potential issue when using the encoder/decoder on a multi-threaded client, as they
were shared between all the threads.

Modified:
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=983657&r1=983656&r2=983657&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Mon Aug  9 14:30:14 2010
@@ -296,7 +296,7 @@ public class LdapNetworkConnection exten
         ResponseFuture<? extends Response> future = futureMap.get( messageId );
 
         // future can be null if there was a abandon operation on that messageId
-        if( future != null )
+        if ( future != null )
         {
             LOG.debug( "Getting <" + messageId + ", " + future.getClass().getName() +
">" );
         }
@@ -376,16 +376,17 @@ public class LdapNetworkConnection exten
     /**
      * Convert a IntermediateResponseCodec to a IntermediateResponse message based on the
ResponseFuture's type
      */
-    private void setIResponse( IntermediateResponseCodec intermediateResponseCodec, ResponseFuture
responseFuture ) throws Exception
+    private void setIResponse( IntermediateResponseCodec intermediateResponseCodec, ResponseFuture
responseFuture )
+        throws Exception
     {
         IntermediateResponse intermediateResponse = null;
 
-        if( responseFuture instanceof SearchFuture )
+        if ( responseFuture instanceof SearchFuture )
         {
             intermediateResponse = new SearchIntermediateResponse();
             addControls( intermediateResponseCodec, ( SearchIntermediateResponse ) intermediateResponse
);
         }
-        else if( responseFuture instanceof ExtendedFuture )
+        else if ( responseFuture instanceof ExtendedFuture )
         {
             intermediateResponse = new ExtendedIntermediateResponse();
             addControls( intermediateResponseCodec, ( ExtendedIntermediateResponse ) intermediateResponse
);
@@ -393,7 +394,8 @@ public class LdapNetworkConnection exten
         else
         {
             // currently we only support IR for search and extended operations
-            throw new UnsupportedOperationException( "Unknown ResponseFuture type " + responseFuture.getClass().getName()
);
+            throw new UnsupportedOperationException( "Unknown ResponseFuture type "
+                + responseFuture.getClass().getName() );
         }
 
         intermediateResponse.setResponseName( intermediateResponseCodec.getResponseName()
);
@@ -439,7 +441,7 @@ public class LdapNetworkConnection exten
         SearchResultEntry searchResultEntry = new SearchResultEntry();
 
         searchResultEntry.setMessageId( searchEntryResultCodec.getMessageId() );
-        if( schemaManager != null )
+        if ( schemaManager != null )
         {
             searchResultEntry.setEntry( new DefaultEntry( schemaManager, searchEntryResultCodec.getEntry()
) );
         }
@@ -1484,7 +1486,7 @@ public class LdapNetworkConnection exten
         }
 
         // Last, not least, reset the MessageId value
-        messageId.set(0);
+        messageId.set( 0 );
 
         // And get out
         LOG.debug( "Unbind successful" );
@@ -1518,11 +1520,11 @@ public class LdapNetworkConnection exten
     {
         if ( cause instanceof ProtocolEncoderException )
         {
-            Throwable realCause = ((ProtocolEncoderException)cause).getCause();
+            Throwable realCause = ( ( ProtocolEncoderException ) cause ).getCause();
 
             if ( realCause instanceof MessageEncoderException )
             {
-                int messageId = ((MessageEncoderException)realCause).getMessageId();
+                int messageId = ( ( MessageEncoderException ) realCause ).getMessageId();
 
                 ResponseFuture<?> response = futureMap.get( messageId );
                 response.cancel( true );
@@ -1560,18 +1562,18 @@ public class LdapNetworkConnection exten
         {
             case ADD_RESPONSE:
                 // Transform the response
-                AddResponseCodec addRespCodec = (AddResponseCodec)response;
+                AddResponseCodec addRespCodec = ( AddResponseCodec ) response;
                 addRespCodec.addControls( response.getControls() );
                 addRespCodec.setMessageId( messageId );
 
                 AddResponse addResponse = convert( addRespCodec );
 
-                AddFuture addFuture = (AddFuture)responseFuture;
+                AddFuture addFuture = ( AddFuture ) responseFuture;
 
                 if ( addFuture == null )
                 {
                     LOG.error( "AddFuture is null" );
-                    throw new LdapException( "AddFuture is null"  );
+                    throw new LdapException( "AddFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1599,17 +1601,17 @@ public class LdapNetworkConnection exten
 
             case BIND_RESPONSE:
                 // Transform the response
-                BindResponseCodec bindResponseCodec = (BindResponseCodec)response;
+                BindResponseCodec bindResponseCodec = ( BindResponseCodec ) response;
                 bindResponseCodec.setMessageId( messageId );
                 bindResponseCodec.addControls( response.getControls() );
                 BindResponse bindResponse = convert( bindResponseCodec );
 
-                BindFuture bindFuture = (BindFuture)responseFuture;
+                BindFuture bindFuture = ( BindFuture ) responseFuture;
 
                 if ( bindFuture == null )
                 {
                     LOG.error( "BindFuture is null" );
-                    throw new LdapException( "BindFuture is null"  );
+                    throw new LdapException( "BindFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1636,18 +1638,18 @@ public class LdapNetworkConnection exten
 
             case COMPARE_RESPONSE:
                 // Transform the response
-                CompareResponseCodec compResCodec = (CompareResponseCodec)response;
+                CompareResponseCodec compResCodec = ( CompareResponseCodec ) response;
                 compResCodec.setMessageId( messageId );
                 compResCodec.addControls( response.getControls() );
 
                 CompareResponse compareResponse = convert( compResCodec );
 
-                CompareFuture compareFuture = (CompareFuture)responseFuture;
+                CompareFuture compareFuture = ( CompareFuture ) responseFuture;
 
                 if ( compareFuture == null )
                 {
                     LOG.error( "CompareFuture is null" );
-                    throw new LdapException( "CompareFuture is null"  );
+                    throw new LdapException( "CompareFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1675,18 +1677,18 @@ public class LdapNetworkConnection exten
 
             case DEL_RESPONSE:
                 // Transform the response
-                DelResponseCodec delRespCodec = (DelResponseCodec)response;
+                DelResponseCodec delRespCodec = ( DelResponseCodec ) response;
                 delRespCodec.addControls( response.getControls() );
                 delRespCodec.setMessageId( messageId );
 
                 DeleteResponse deleteResponse = convert( delRespCodec );
 
-                DeleteFuture deleteFuture = (DeleteFuture)responseFuture;
+                DeleteFuture deleteFuture = ( DeleteFuture ) responseFuture;
 
                 if ( deleteFuture == null )
                 {
                     LOG.error( "DeleteFuture is null" );
-                    throw new LdapException( "DeleteFuture is null"  );
+                    throw new LdapException( "DeleteFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1713,18 +1715,18 @@ public class LdapNetworkConnection exten
 
             case EXTENDED_RESPONSE:
                 // Transform the response
-                ExtendedResponseCodec extResCodec = (ExtendedResponseCodec)response;
+                ExtendedResponseCodec extResCodec = ( ExtendedResponseCodec ) response;
                 extResCodec.setMessageId( messageId );
                 extResCodec.addControls( response.getControls() );
 
                 ExtendedResponse extendedResponse = convert( extResCodec );
 
-                ExtendedFuture extendedFuture = (ExtendedFuture)responseFuture;
+                ExtendedFuture extendedFuture = ( ExtendedFuture ) responseFuture;
 
                 if ( extendedFuture == null )
                 {
                     LOG.error( "ExtendedFuture is null" );
-                    throw new LdapException( "extendedFuture is null"  );
+                    throw new LdapException( "extendedFuture is null" );
                 }
 
                 // remove the listener from the listener map
@@ -1751,7 +1753,7 @@ public class LdapNetworkConnection exten
                 break;
 
             case INTERMEDIATE_RESPONSE:
-                IntermediateResponseCodec intermediateResponseCodec = (IntermediateResponseCodec)response;
+                IntermediateResponseCodec intermediateResponseCodec = ( IntermediateResponseCodec
) response;
                 intermediateResponseCodec.setMessageId( messageId );
                 intermediateResponseCodec.addControls( response.getControls() );
 
@@ -1761,18 +1763,18 @@ public class LdapNetworkConnection exten
 
             case MODIFY_RESPONSE:
                 // Transform the response
-                ModifyResponseCodec modRespCodec = (ModifyResponseCodec)response;
+                ModifyResponseCodec modRespCodec = ( ModifyResponseCodec ) response;
                 modRespCodec.setMessageId( messageId );
                 modRespCodec.addControls( response.getControls() );
 
                 ModifyResponse modifyResp = convert( modRespCodec );
 
-                ModifyFuture modifyFuture = (ModifyFuture)responseFuture;
+                ModifyFuture modifyFuture = ( ModifyFuture ) responseFuture;
 
                 if ( modifyFuture == null )
                 {
                     LOG.error( "ModifyFuture is null" );
-                    throw new LdapException( "ModifyFuture is null"  );
+                    throw new LdapException( "ModifyFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1799,18 +1801,18 @@ public class LdapNetworkConnection exten
 
             case MODIFYDN_RESPONSE:
                 // Transform the response
-                ModifyDNResponseCodec modDnRespCodec = (ModifyDNResponseCodec)response;
+                ModifyDNResponseCodec modDnRespCodec = ( ModifyDNResponseCodec ) response;
                 modDnRespCodec.setMessageId( messageId );
                 modDnRespCodec.addControls( response.getControls() );
 
                 ModifyDnResponse modifyDnResp = convert( modDnRespCodec );
 
-                ModifyDnFuture modifyDnFuture = (ModifyDnFuture)responseFuture;
+                ModifyDnFuture modifyDnFuture = ( ModifyDnFuture ) responseFuture;
 
                 if ( modifyDnFuture == null )
                 {
                     LOG.error( "ModifyDNFuture is null" );
-                    throw new LdapException( "ModifyDNFuture is null"  );
+                    throw new LdapException( "ModifyDNFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1837,17 +1839,17 @@ public class LdapNetworkConnection exten
 
             case SEARCH_RESULT_DONE:
                 // Store the response into the responseQueue
-                SearchResultDoneCodec searchResultDoneCodec = (SearchResultDoneCodec)response;
+                SearchResultDoneCodec searchResultDoneCodec = ( SearchResultDoneCodec ) response;
                 searchResultDoneCodec.setMessageId( messageId );
                 searchResultDoneCodec.addControls( response.getControls() );
                 SearchResultDone searchResultDone = convert( searchResultDoneCodec );
 
-                SearchFuture searchFuture = (SearchFuture)responseFuture;
+                SearchFuture searchFuture = ( SearchFuture ) responseFuture;
 
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
-                    throw new LdapException( "SearchFuture is null"  );
+                    throw new LdapException( "SearchFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1874,18 +1876,18 @@ public class LdapNetworkConnection exten
 
             case SEARCH_RESULT_ENTRY:
                 // Store the response into the responseQueue
-                SearchResultEntryCodec searchResultEntryCodec = (SearchResultEntryCodec)response;
+                SearchResultEntryCodec searchResultEntryCodec = ( SearchResultEntryCodec
) response;
                 searchResultEntryCodec.setMessageId( messageId );
                 searchResultEntryCodec.addControls( response.getControls() );
 
                 SearchResultEntry srchEntry = convert( searchResultEntryCodec );
 
-                searchFuture = (SearchFuture)responseFuture;
+                searchFuture = ( SearchFuture ) responseFuture;
 
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
-                    throw new LdapException( "SearchFuture is null"  );
+                    throw new LdapException( "SearchFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1900,18 +1902,18 @@ public class LdapNetworkConnection exten
 
             case SEARCH_RESULT_REFERENCE:
                 // Store the response into the responseQueue
-                SearchResultReferenceCodec searchResultReferenceCodec = (SearchResultReferenceCodec)response;
+                SearchResultReferenceCodec searchResultReferenceCodec = ( SearchResultReferenceCodec
) response;
                 searchResultReferenceCodec.setMessageId( messageId );
                 searchResultReferenceCodec.addControls( response.getControls() );
 
                 SearchResultReference searchResultReference = convert( searchResultReferenceCodec
);
 
-                searchFuture = (SearchFuture)responseFuture;
+                searchFuture = ( SearchFuture ) responseFuture;
 
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
-                    throw new LdapException( "SearchFuture is null"  );
+                    throw new LdapException( "SearchFuture is null" );
                 }
 
                 if ( LOG.isDebugEnabled() )
@@ -1977,7 +1979,7 @@ public class LdapNetworkConnection exten
      */
     public ModifyResponse modify( String dn, Modification... modifications ) throws LdapException
     {
-        return modify ( new DN( dn ), modifications );
+        return modify( new DN( dn ), modifications );
     }
 
 
@@ -2418,8 +2420,8 @@ public class LdapNetworkConnection exten
         }
         else
         {
-            String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported
by the server\n" +
-                " The deletion has been aborted";
+            String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported
by the server\n"
+                + " The deletion has been aborted";
             LOG.error( msg );
             throw new LdapException( msg );
         }
@@ -2448,8 +2450,8 @@ public class LdapNetworkConnection exten
             }
             else
             {
-                String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported
by the server\n" +
-                    " The deletion has been aborted";
+                String msg = "The subtreeDelete control (1.2.840.113556.1.4.805) is not supported
by the server\n"
+                    + " The deletion has been aborted";
                 LOG.error( msg );
                 throw new LdapException( msg );
             }
@@ -2493,8 +2495,8 @@ public class LdapNetworkConnection exten
      * @param listener  the delete operation response listener
      * @throws LdapException If the DN is not valid or if the deletion failed
      */
-    private DeleteResponse deleteRecursive( DN dn, Map<DN, Cursor<SearchResponse>>
cursorMap,
-        DeleteListener listener ) throws LdapException
+    private DeleteResponse deleteRecursive( DN dn, Map<DN, Cursor<SearchResponse>>
cursorMap, DeleteListener listener )
+        throws LdapException
     {
         LOG.debug( "searching for {}", dn.getName() );
         DeleteResponse delResponse = null;
@@ -3055,7 +3057,7 @@ public class LdapNetworkConnection exten
             // And close the cursor
             cursor.close();
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             throw new LdapException( e );
         }
@@ -3133,7 +3135,7 @@ public class LdapNetworkConnection exten
 
         EntryAttribute attr = rootDSE.get( SchemaConstants.SUPPORTED_CONTROL_AT );
 
-        for (Value<?> value:attr)
+        for ( Value<?> value : attr )
         {
             supportedControls.add( value.getString() );
         }
@@ -3155,25 +3157,25 @@ public class LdapNetworkConnection exten
 
             // we enale all the schemas so that need not check with server for enabled schemas
             Collection<Schema> schemas = schemaManager.getLoader().getAllSchemas();
-            for( Schema s : schemas )
+            for ( Schema s : schemas )
             {
                 s.enable();
             }
 
             schemaManager.loadAllEnabled();
 
-            if( ! schemaManager.getErrors().isEmpty() )
+            if ( !schemaManager.getErrors().isEmpty() )
             {
                 String msg = "there are errors while loading the schema";
                 LOG.error( msg + " {}", schemaManager.getErrors() );
                 throw new LdapException( msg );
             }
         }
-        catch( LdapException le )
+        catch ( LdapException le )
         {
             throw le;
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             LOG.error( "failed to load the schema", e );
             throw new LdapException( e );
@@ -3192,7 +3194,7 @@ public class LdapNetworkConnection exten
     {
         try
         {
-            if( schemaManager == null )
+            if ( schemaManager == null )
             {
                 loadSchema();
             }
@@ -3203,21 +3205,21 @@ public class LdapNetworkConnection exten
 
             List<AttributeType> atList = olsp.getAttributeTypes();
             AttributeTypeRegistry atRegistry = schemaManager.getRegistries().getAttributeTypeRegistry();
-            for( AttributeType atType : atList )
+            for ( AttributeType atType : atList )
             {
                 atRegistry.addMappingFor( atType );
             }
 
             List<ObjectClass> ocList = olsp.getObjectClassTypes();
             ObjectClassRegistry ocRegistry = schemaManager.getRegistries().getObjectClassRegistry();
-            for( ObjectClass oc : ocList )
+            for ( ObjectClass oc : ocList )
             {
                 ocRegistry.register( oc );
             }
 
             LOG.info( "successfully loaded the schema from file {}", schemaFile.getAbsolutePath()
);
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             LOG.error( "failed to load the schema from file {}", schemaFile.getAbsolutePath()
);
             throw new LdapException( e );
@@ -3347,7 +3349,7 @@ public class LdapNetworkConnection exten
 
     public void addConnectionClosedEventListener( ConnectionClosedEventListener ccListenr
)
     {
-        if( conCloseListeners == null )
+        if ( conCloseListeners == null )
         {
             conCloseListeners = new ArrayList<ConnectionClosedEventListener>();
         }
@@ -3360,7 +3362,7 @@ public class LdapNetworkConnection exten
     public void sessionClosed( IoSession session ) throws Exception
     {
         // no need to handle if this session was closed by the user
-        if( !connected.get() )
+        if ( !connected.get() )
         {
             return;
         }
@@ -3378,10 +3380,10 @@ public class LdapNetworkConnection exten
 
         clearMaps();
 
-        if( conCloseListeners != null )
+        if ( conCloseListeners != null )
         {
             LOG.debug( "notifying the registered ConnectionClosedEventListeners.." );
-            for( ConnectionClosedEventListener listener : conCloseListeners )
+            for ( ConnectionClosedEventListener listener : conCloseListeners )
             {
                 listener.connectionClosed();
             }

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java?rev=983657&r1=983656&r2=983657&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
(original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolCodecFactory.java
Mon Aug  9 14:30:14 2010
@@ -19,11 +19,13 @@
  */
 package org.apache.directory.ldap.client.api.protocol;
 
+
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
 
+
 /**
  * 
  * The factory used to create the LDAP encoder and decoder.
@@ -32,13 +34,13 @@ import org.apache.mina.filter.codec.Prot
  */
 public class LdapProtocolCodecFactory implements ProtocolCodecFactory
 {
-    /** The Ldap encoder */
-    private ProtocolEncoder ldapEncoder;
-    
-    /** The Ldap decoder */
-    private ProtocolDecoder ldapDecoder;
+    /** The LdapDecoder key */
+    public static final String LDAP_DECODER = "LDAP_DECODER";
+
+    /** The LdapEncoder key */
+    public static final String LDAP_ENCODER = "LDAP_ENCODER";
+
 
-    
     /**
      * 
      * Creates a new instance of LdapProtocolCodecFactory. It
@@ -47,26 +49,23 @@ public class LdapProtocolCodecFactory im
      */
     public LdapProtocolCodecFactory()
     {
-        // Create the encoder.
-        ldapEncoder = new LdapProtocolEncoder();
-        ldapDecoder = new LdapProtocolDecoder();
     }
-    
-    
+
+
     /**
      * Get the Ldap decoder. 
      */
     public ProtocolDecoder getDecoder( IoSession session ) throws Exception
     {
-        return ldapDecoder;
+        return new LdapProtocolDecoder();
     }
-    
+
 
     /**
      * Get the Ldap encoder.
      */
     public ProtocolEncoder getEncoder( IoSession session ) throws Exception
     {
-        return ldapEncoder;
-    }    
+        return new LdapProtocolEncoder();
+    }
 }

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java?rev=983657&r1=983656&r2=983657&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
(original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
Mon Aug  9 14:30:14 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.ldap.client.api.protocol;
 
+
 import java.nio.ByteBuffer;
 
 import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
@@ -27,6 +28,7 @@ import org.apache.mina.core.session.IoSe
 import org.apache.mina.filter.codec.ProtocolEncoder;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 
+
 /**
  * 
  * A LDAP encoder.
@@ -46,16 +48,13 @@ public class LdapProtocolEncoder impleme
     {
         if ( request instanceof LdapMessageCodec )
         {
-            LdapMessageCodec ldapRequest = (LdapMessageCodec)request;
-            
+            LdapMessageCodec ldapRequest = ( LdapMessageCodec ) request;
+
             ByteBuffer bb = ldapRequest.encode();
             bb.flip();
-            
-            IoBuffer buffer = IoBuffer.allocate( bb.limit(), false );
-            buffer.setAutoExpand( false );
-            buffer.put( bb );
-            buffer.flip();
-            
+
+            IoBuffer buffer = IoBuffer.wrap( bb );
+
             out.write( buffer );
         }
         else
@@ -63,8 +62,8 @@ public class LdapProtocolEncoder impleme
             throw new Exception();
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */



Mime
View raw message