You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2019/01/06 06:04:34 UTC
[directory-ldap-api] branch master updated: o Used a TLS to store
the encoding buffer o Cleaned up the LdapNetworkConnection class,
removing some Sonar warnings o Referred to project 44-SNAPSHOT o Bumped up
some dependencies
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git
The following commit(s) were added to refs/heads/master by this push:
new c783a2b o Used a TLS to store the encoding buffer o Cleaned up the LdapNetworkConnection class, removing some Sonar warnings o Referred to project 44-SNAPSHOT o Bumped up some dependencies
c783a2b is described below
commit c783a2bc634ea0a5db6b717d8fc508012859b260
Author: Emmanuel Lecharny <el...@apache.org>
AuthorDate: Sun Jan 6 07:04:32 2019 +0100
o Used a TLS to store the encoding buffer
o Cleaned up the LdapNetworkConnection class, removing some Sonar
warnings
o Referred to project 44-SNAPSHOT
o Bumped up some dependencies
---
.../ldap/client/api/LdapNetworkConnection.java | 604 +++++++++++----------
.../client/api/future/MultipleResponseFuture.java | 1 +
.../codec/protocol/mina/LdapProtocolEncoder.java | 26 +-
pom.xml | 10 +-
4 files changed, 352 insertions(+), 289 deletions(-)
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index 596cbf7..4ee86d9 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -163,8 +163,6 @@ import org.apache.directory.ldap.client.api.future.SearchFuture;
import org.apache.mina.core.filterchain.IoFilter;
import org.apache.mina.core.future.CloseFuture;
import org.apache.mina.core.future.ConnectFuture;
-import org.apache.mina.core.future.IoFuture;
-import org.apache.mina.core.future.IoFutureListener;
import org.apache.mina.core.future.WriteFuture;
import org.apache.mina.core.service.IoConnector;
import org.apache.mina.core.session.IoSession;
@@ -822,10 +820,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
CloseFuture closeFuture = connectionFuture.getSession().getCloseFuture();
// Add a listener to close the session in the session.
- closeFuture.addListener( new IoFutureListener<IoFuture>()
- {
- @Override
- public void operationComplete( IoFuture future )
+ closeFuture.addListener( future ->
{
// Process all the waiting operations and cancel them
if ( LOG.isDebugEnabled() )
@@ -886,8 +881,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
}
futureMap.clear();
- }
- } );
+ } );
// Get back the session
ldapSession = connectionFuture.getSession();
@@ -1237,7 +1231,10 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
else
{
// this shouldn't happen
- LOG.warn( I18n.msg( I18n.MSG_04165_NO_FUTURE_ASSOCIATED_TO_MSG_ID_COMPLETED, abandonId ) );
+ if ( LOG.isWarnEnabled() )
+ {
+ LOG.warn( I18n.msg( I18n.MSG_04165_NO_FUTURE_ASSOCIATED_TO_MSG_ID_COMPLETED, abandonId ) );
+ }
}
}
@@ -2461,6 +2458,305 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
/**
+ * Process the AddResponse received from the server
+ */
+ private void addReceived( AddResponse addResponse, AddFuture addFuture, int responseId ) throws InterruptedException
+ {
+ // remove the listener from the listener map
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ LOG.debug( I18n.msg( I18n.MSG_04108_ADD_SUCCESSFUL, addResponse ) );
+ }
+ else
+ {
+ // We have had an error
+ LOG.debug( I18n.msg( I18n.MSG_04107_ADD_FAILED, addResponse ) );
+ }
+ }
+
+ // Store the response into the future
+ addFuture.set( addResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the BindResponse received from the server
+ */
+ private void bindReceived( BindResponse bindResponse, BindFuture bindFuture, int responseId ) throws InterruptedException
+ {
+ // remove the listener from the listener map
+ if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ authenticated.set( true );
+
+ // Everything is fine, return the response
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04101_BIND_SUCCESSFUL, bindResponse ) );
+ }
+ }
+ else
+ {
+ // We have had an error
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04100_BIND_FAIL, bindResponse ) );
+ }
+ }
+
+ // Store the response into the future
+ bindFuture.set( bindResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the CompareResponse received from the server
+ */
+ private void compareReceived( CompareResponse compareResponse, CompareFuture compareFuture, int responseId ) throws InterruptedException
+ {
+ // remove the listener from the listener map
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( compareResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ LOG.debug( I18n.msg( I18n.MSG_04114_COMPARE_SUCCESSFUL, compareResponse ) );
+ }
+ else
+ {
+ // We have had an error
+ LOG.debug( I18n.msg( I18n.MSG_04113_COMPARE_FAILED, compareResponse ) );
+ }
+ }
+
+ // Store the response into the future
+ compareFuture.set( compareResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the DeleteResponse received from the server
+ */
+ private void deleteReceived( DeleteResponse deleteResponse, DeleteFuture deleteFuture, int responseId ) throws InterruptedException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ LOG.debug( I18n.msg( I18n.MSG_04116_DELETE_SUCCESSFUL, deleteResponse ) );
+ }
+ else
+ {
+ // We have had an error
+ LOG.debug( I18n.msg( I18n.MSG_04115_DELETE_FAILED, deleteResponse ) );
+ }
+ }
+
+ // Store the response into the future
+ deleteFuture.set( deleteResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the ExtendedResponse received from the server
+ */
+ private void extendedReceived( ExtendedResponse extendedResponse, ExtendedFuture extendedFuture, int responseId )
+ throws InterruptedException, DecoderException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( extendedResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ LOG.debug( I18n.msg( I18n.MSG_04118_EXTENDED_SUCCESSFUL, extendedResponse ) );
+ }
+ else
+ {
+ // We have had an error
+ LOG.debug( I18n.msg( I18n.MSG_04117_EXTENDED_FAILED, extendedResponse ) );
+ }
+ }
+
+ extendedResponse = handleOpaqueResponse( extendedResponse, extendedFuture );
+
+ // Store the response into the future
+ extendedFuture.set( extendedResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the IntermediateResponse received from the server
+ */
+ private void intermediateReceived( IntermediateResponse intermediateResponse, ResponseFuture<? extends Response> responseFuture )
+ throws InterruptedException
+ {
+ // Store the response into the future
+ if ( responseFuture instanceof SearchFuture )
+ {
+ ( ( SearchFuture ) responseFuture ).set( intermediateResponse );
+ }
+ else if ( responseFuture instanceof ExtendedFuture )
+ {
+ ( ( ExtendedFuture ) responseFuture ).set( intermediateResponse );
+ }
+ else
+ {
+ // currently we only support IR for search and extended operations
+ throw new UnsupportedOperationException( I18n.err( I18n.ERR_04111_UNKNOWN_RESPONSE_FUTURE_TYPE,
+ responseFuture.getClass().getName() ) );
+ }
+
+ // Do not remove the future from the map, that's done when receiving search result done
+ }
+
+
+ /**
+ * Process the ModifyResponse received from the server
+ */
+ private void modifyReceived( ModifyResponse modifyResponse, ModifyFuture modifyFuture, int responseId )
+ throws InterruptedException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04123_MODIFY_SUCCESSFUL, modifyResponse ) );
+ }
+ }
+ else
+ {
+ // We have had an error
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04122_MODIFY_FAILED, modifyResponse ) );
+ }
+ }
+ }
+
+ // Store the response into the future
+ modifyFuture.set( modifyResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the ModifyDnResponse received from the server
+ */
+ private void modifyDnReceived( ModifyDnResponse modifyDnResponse, ModifyDnFuture modifyDnFuture, int responseId )
+ throws InterruptedException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ LOG.debug( I18n.msg( I18n.MSG_04125_MODIFYDN_SUCCESSFUL, modifyDnResponse ) );
+ }
+ else
+ {
+ // We have had an error
+ LOG.debug( I18n.msg( I18n.MSG_04124_MODIFYDN_FAILED, modifyDnResponse ) );
+ }
+ }
+
+ // Store the response into the future
+ modifyDnFuture.set( modifyDnResponse );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the SearchResultDone received from the server
+ */
+ private void searchResultDoneReceived( SearchResultDone searchResultDone, SearchFuture searchFuture,
+ int responseId ) throws InterruptedException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ if ( searchResultDone.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+ {
+ // Everything is fine, return the response
+ LOG.debug( I18n.msg( I18n.MSG_04131_SEARCH_SUCCESSFUL, searchResultDone ) );
+ }
+ else
+ {
+ // We have had an error
+ LOG.debug( I18n.msg( I18n.MSG_04129_SEARCH_FAILED, searchResultDone ) );
+ }
+ }
+
+ // Store the response into the future
+ searchFuture.set( searchResultDone );
+
+ // Remove the future from the map
+ removeFromFutureMaps( responseId );
+ }
+
+
+ /**
+ * Process the SearchResultEntry received from the server
+ */
+ private void searchResultEntryReceived( SearchResultEntry searchResultEntry, SearchFuture searchFuture )
+ throws InterruptedException, LdapException
+ {
+ if ( schemaManager != null )
+ {
+ searchResultEntry.setEntry( new DefaultEntry( schemaManager, searchResultEntry.getEntry() ) );
+ }
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04128_SEARCH_ENTRY_FOUND, searchResultEntry ) );
+ }
+
+ // Store the response into the future
+ searchFuture.set( searchResultEntry );
+ }
+
+
+ /**
+ * Process the SearchResultEntry received from the server
+ */
+ private void searchResultReferenceReceived( SearchResultReference searchResultReference, SearchFuture searchFuture )
+ throws InterruptedException, LdapException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( I18n.msg( I18n.MSG_04130_SEARCH_REFERENCE_FOUND, searchResultReference ) );
+ }
+
+ // Store the response into the future
+ searchFuture.set( searchResultReference );
+ }
+
+
+ /**
* Handle the incoming LDAP messages. This is where we feed the cursor for search
* requests, or call the listener.
*
@@ -2472,18 +2768,18 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
public void messageReceived( IoSession session, Object message ) throws Exception
{
// Feed the response and store it into the session
- Message response = ( Message ) message;
+ Response response = ( Response ) message;
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_04142_MESSAGE_RECEIVED, response ) );
}
- int messageId = response.getMessageId();
+ int responseId = response.getMessageId();
// this check is necessary to prevent adding an abandoned operation's
// result(s) to corresponding queue
- ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( messageId );
+ ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( responseId );
boolean isNoD = isNoticeOfDisconnect( response );
@@ -2491,7 +2787,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
{
if ( LOG.isInfoEnabled() )
{
- LOG.info( I18n.msg( I18n.MSG_04166_NO_FUTURE_ASSOCIATED_TO_MSG_ID_IGNORING, messageId ) );
+ LOG.info( I18n.msg( I18n.MSG_04166_NO_FUTURE_ASSOCIATED_TO_MSG_ID_IGNORING, responseId ) );
}
return;
@@ -2508,302 +2804,57 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
switch ( response.getType() )
{
case ADD_RESPONSE:
- // Transform the response
- AddResponse addResponse = ( AddResponse ) response;
-
- AddFuture addFuture = ( AddFuture ) responseFuture;
-
- // remove the listener from the listener map
- if ( LOG.isDebugEnabled() )
- {
- if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- LOG.debug( I18n.msg( I18n.MSG_04108_ADD_SUCCESSFUL, addResponse ) );
- }
- else
- {
- // We have had an error
- LOG.debug( I18n.msg( I18n.MSG_04107_ADD_FAILED, addResponse ) );
- }
- }
-
- // Store the response into the future
- addFuture.set( addResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ addReceived( ( AddResponse ) response, ( AddFuture ) responseFuture, responseId );
break;
case BIND_RESPONSE:
- // Transform the response
- BindResponse bindResponse = ( BindResponse ) response;
-
- BindFuture bindFuture = ( BindFuture ) responseFuture;
-
- // remove the listener from the listener map
- if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- authenticated.set( true );
-
- // Everything is fine, return the response
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( I18n.msg( I18n.MSG_04101_BIND_SUCCESSFUL, bindResponse ) );
- }
- }
- else
- {
- // We have had an error
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( I18n.msg( I18n.MSG_04100_BIND_FAIL, bindResponse ) );
- }
- }
-
- // Store the response into the future
- bindFuture.set( bindResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ bindReceived( ( BindResponse ) response, ( BindFuture ) responseFuture, responseId );
break;
case COMPARE_RESPONSE:
- // Transform the response
- CompareResponse compareResponse = ( CompareResponse ) response;
-
- CompareFuture compareFuture = ( CompareFuture ) responseFuture;
-
- // remove the listener from the listener map
- if ( LOG.isDebugEnabled() )
- {
- if ( compareResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- LOG.debug( I18n.msg( I18n.MSG_04114_COMPARE_SUCCESSFUL, compareResponse ) );
- }
- else
- {
- // We have had an error
- LOG.debug( I18n.msg( I18n.MSG_04113_COMPARE_FAILED, compareResponse ) );
- }
- }
-
- // Store the response into the future
- compareFuture.set( compareResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ compareReceived( ( CompareResponse ) response, ( CompareFuture ) responseFuture, responseId );
break;
case DEL_RESPONSE:
- // Transform the response
- DeleteResponse deleteResponse = ( DeleteResponse ) response;
-
- DeleteFuture deleteFuture = ( DeleteFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- LOG.debug( I18n.msg( I18n.MSG_04116_DELETE_SUCCESSFUL, deleteResponse ) );
- }
- else
- {
- // We have had an error
- LOG.debug( I18n.msg( I18n.MSG_04115_DELETE_FAILED, deleteResponse ) );
- }
- }
-
- // Store the response into the future
- deleteFuture.set( deleteResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ deleteReceived( ( DeleteResponse ) response, ( DeleteFuture ) responseFuture, responseId );
break;
case EXTENDED_RESPONSE:
- // Transform the response
- ExtendedResponse extendedResponse = ( ExtendedResponse ) response;
-
- ExtendedFuture extendedFuture = ( ExtendedFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- if ( extendedResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- LOG.debug( I18n.msg( I18n.MSG_04118_EXTENDED_SUCCESSFUL, extendedResponse ) );
- }
- else
- {
- // We have had an error
- LOG.debug( I18n.msg( I18n.MSG_04117_EXTENDED_FAILED, extendedResponse ) );
- }
- }
-
- extendedResponse = handleOpaqueResponse( extendedResponse, extendedFuture );
-
- // Store the response into the future
- extendedFuture.set( extendedResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ extendedReceived( ( ExtendedResponse ) response, ( ExtendedFuture ) responseFuture, responseId );
break;
case INTERMEDIATE_RESPONSE:
- IntermediateResponse intermediateResponse = ( IntermediateResponse ) response;
-
- // Store the response into the future
- if ( responseFuture instanceof SearchFuture )
- {
- ( ( SearchFuture ) responseFuture ).set( intermediateResponse );
- }
- else if ( responseFuture instanceof ExtendedFuture )
- {
- ( ( ExtendedFuture ) responseFuture ).set( intermediateResponse );
- }
- else
- {
- // currently we only support IR for search and extended operations
- throw new UnsupportedOperationException( I18n.err( I18n.ERR_04111_UNKNOWN_RESPONSE_FUTURE_TYPE,
- responseFuture.getClass().getName() ) );
- }
-
- // Do not remove the future from the map, that's done when receiving search result done
+ intermediateReceived( ( IntermediateResponse ) response, responseFuture );
break;
case MODIFY_RESPONSE:
- // Transform the response
- ModifyResponse modifyResponse = ( ModifyResponse ) response;
-
- ModifyFuture modifyFuture = ( ModifyFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- if ( modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( I18n.msg( I18n.MSG_04123_MODIFY_SUCCESSFUL, modifyResponse ) );
- }
- }
- else
- {
- // We have had an error
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( I18n.msg( I18n.MSG_04122_MODIFY_FAILED, modifyResponse ) );
- }
- }
- }
-
- // Store the response into the future
- modifyFuture.set( modifyResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ modifyReceived( ( ModifyResponse ) response, ( ModifyFuture ) responseFuture, responseId );
break;
case MODIFYDN_RESPONSE:
- // Transform the response
- ModifyDnResponse modifyDnResponse = ( ModifyDnResponse ) response;
-
- ModifyDnFuture modifyDnFuture = ( ModifyDnFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- LOG.debug( I18n.msg( I18n.MSG_04125_MODIFYDN_SUCCESSFUL, modifyDnResponse ) );
- }
- else
- {
- // We have had an error
- LOG.debug( I18n.msg( I18n.MSG_04124_MODIFYDN_FAILED, modifyDnResponse ) );
- }
- }
-
- // Store the response into the future
- modifyDnFuture.set( modifyDnResponse );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ modifyDnReceived( ( ModifyDnResponse ) response, ( ModifyDnFuture ) responseFuture, responseId );
break;
case SEARCH_RESULT_DONE:
- // Store the response into the responseQueue
- SearchResultDone searchResultDone = ( SearchResultDone ) response;
-
- SearchFuture searchFuture = ( SearchFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- if ( searchResultDone.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
- {
- // Everything is fine, return the response
- LOG.debug( I18n.msg( I18n.MSG_04131_SEARCH_SUCCESSFUL, searchResultDone ) );
- }
- else
- {
- // We have had an error
- LOG.debug( I18n.msg( I18n.MSG_04129_SEARCH_FAILED, searchResultDone ) );
- }
- }
-
- // Store the response into the future
- searchFuture.set( searchResultDone );
-
- // Remove the future from the map
- removeFromFutureMaps( messageId );
+ searchResultDoneReceived( ( SearchResultDone ) response, ( SearchFuture ) responseFuture, responseId );
break;
case SEARCH_RESULT_ENTRY:
- // Store the response into the responseQueue
- SearchResultEntry searchResultEntry = ( SearchResultEntry ) response;
-
- if ( schemaManager != null )
- {
- searchResultEntry.setEntry( new DefaultEntry( schemaManager, searchResultEntry.getEntry() ) );
- }
-
- searchFuture = ( SearchFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( I18n.msg( I18n.MSG_04128_SEARCH_ENTRY_FOUND, searchResultEntry ) );
- }
-
- // Store the response into the future
- searchFuture.set( searchResultEntry );
+ searchResultEntryReceived( ( SearchResultEntry ) response, ( SearchFuture ) responseFuture );
break;
case SEARCH_RESULT_REFERENCE:
- // Store the response into the responseQueue
- SearchResultReference searchResultReference = ( SearchResultReference ) response;
-
- searchFuture = ( SearchFuture ) responseFuture;
-
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( I18n.msg( I18n.MSG_04130_SEARCH_REFERENCE_FOUND, searchResultReference ) );
- }
-
- // Store the response into the future
- searchFuture.set( searchResultReference );
+ searchResultReferenceReceived( ( SearchResultReference ) response, ( SearchFuture ) responseFuture );
break;
@@ -4999,16 +5050,13 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
Exception exception = ( Exception ) ldapSession.removeAttribute( EXCEPTION_KEY );
- if ( exception != null )
+ if ( exception instanceof LdapException )
{
- if ( exception instanceof LdapException )
- {
- throw ( LdapException ) exception;
- }
- else
- {
- throw new InvalidConnectionException( exception.getMessage(), exception );
- }
+ throw ( LdapException ) exception;
+ }
+ else if ( exception != null )
+ {
+ throw new InvalidConnectionException( exception.getMessage(), exception );
}
throw new InvalidConnectionException( I18n.err( I18n.ERR_04160_SESSION_HAS_BEEN_CLOSED ) );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/MultipleResponseFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/MultipleResponseFuture.java
index e6b3a5c..0e6e4af 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/MultipleResponseFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/MultipleResponseFuture.java
@@ -110,6 +110,7 @@ public abstract class MultipleResponseFuture<R extends Response> implements Resp
* @param response The response to add into the Future
* @throws InterruptedException if the operation has been cancelled by client
*/
+ @Override
public void set( R response ) throws InterruptedException
{
queue.add( response );
diff --git a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java
index 73c3703..19795cb 100644
--- a/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java
+++ b/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolEncoder.java
@@ -49,9 +49,12 @@ public class LdapProtocolEncoder implements ProtocolEncoder
/** logger for reporting errors that might not be handled properly upstream */
private static final Logger CODEC_LOG = LoggerFactory.getLogger( Loggers.CODEC_LOG.getName() );
-
+ /** The LDAP API Service instance */
private LdapApiService codec;
-
+
+ /** A thread local storage used to store the Asn1Buffer instance */
+ private ThreadLocal<Asn1Buffer> threadLocalStorage = new ThreadLocal<>();
+
/**
* Creates a new instance of LdapProtocolEncoder.
*/
@@ -77,22 +80,33 @@ public class LdapProtocolEncoder implements ProtocolEncoder
@Override
public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws Exception
{
- Asn1Buffer asn1Buffer = new Asn1Buffer();
+ Asn1Buffer asn1Buffer = threadLocalStorage.get();
+
+ if ( asn1Buffer == null )
+ {
+ asn1Buffer = new Asn1Buffer();
+ threadLocalStorage.set( asn1Buffer );
+ }
+
+ ByteBuffer encoded;
try
{
LdapEncoder.encodeMessage( asn1Buffer, codec, ( Message ) message );
+ encoded = asn1Buffer.getBytes();
}
catch ( EncoderException e )
{
CODEC_LOG.error( I18n.err( I18n.ERR_14000_ERROR_ENCODING_MESSAGE, message, e.getMessage() ) );
throw e;
}
-
- ByteBuffer encoded = asn1Buffer.getBytes();
+ finally
+ {
+ asn1Buffer.clear();
+ }
IoBuffer ioBuffer = IoBuffer.wrap( encoded );
-
+
if ( CODEC_LOG.isDebugEnabled() )
{
byte[] dumpBuffer = new byte[encoded.limit()];
diff --git a/pom.xml b/pom.xml
index 51bec22..be02c96 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.project</groupId>
<artifactId>project</artifactId>
- <version>43</version>
+ <version>44-SNAPSHOT</version>
<relativePath />
</parent>
@@ -41,7 +41,7 @@
<!-- Set versions for depending projects -->
<skin.version>1.0.3</skin.version>
<org.apache.directory.junit.junit-addons.version>2.0.0</org.apache.directory.junit.junit-addons.version>
- <org.apache.directory.checkstyle-configuration.version>0.3</org.apache.directory.checkstyle-configuration.version>
+ <org.apache.directory.checkstyle-configuration.version>2.0.0</org.apache.directory.checkstyle-configuration.version>
<!-- Set versions for depending jars -->
<antlr.version>2.7.7</antlr.version>
@@ -57,7 +57,7 @@
<mina.core.version>2.0.18</mina.core.version>
<org.osgi.core.version>6.0.0</org.osgi.core.version>
<org.apache.felix.version>6.0.1</org.apache.felix.version>
- <pax-exam.version>4.12.0</pax-exam.version>
+ <pax-exam.version>4.13.1</pax-exam.version>
<pax-url.version>2.5.4</pax-url.version>
<slf4j.api.version>1.7.25</slf4j.api.version>
<slf4j.api.bundleversion>"$«range;[==,=+)»"</slf4j.api.bundleversion>
@@ -278,13 +278,13 @@
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
- <version>2.1</version>
+ <version>3.2.0</version>
</dependency>
<!-- Add support for 'scpexe' -->
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
- <version>2.1</version>
+ <version>3.2.0</version>
</dependency>
<!-- Needed for mvn site to work.-->
<dependency>