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 2026/05/25 12:41:42 UTC

(directory-ldap-api) branch master updated: Improved the timeout message (DIRAPI-432)

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits 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 7352c3966 Improved the timeout message (DIRAPI-432)
7352c3966 is described below

commit 7352c396615c07efb305964495dcdeb8c7922d68
Author: Emmanuel Lécharny <em...@worteks.com>
AuthorDate: Mon May 25 14:41:12 2026 +0200

    Improved the timeout message (DIRAPI-432)
---
 .../apache/directory/api/i18n/errors.properties    |  2 +-
 .../directory/ldap/client/api/EntryCursorImpl.java |  2 +-
 .../ldap/client/api/LdapNetworkConnection.java     | 44 +++++++++++-----------
 .../ldap/client/api/SearchCursorImpl.java          |  3 +-
 4 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
index d65168152..285d0a17e 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
@@ -196,7 +196,7 @@ ERR_04166_ONE_FILTER_REQUIRED=At least one filter required
 ERR_04167_FILTER_NOT_SET=Filter not set
 ERR_04168_TRIM_LOWERCASE_FOR_CHAR_ARRAY=Trim and lowerCase only applicable to char[]
 ERR_04169_RESPONSE_QUEUE_EMPTIED=The response queue has been emptied, no response was found.
-ERR_04170_TIMEOUT_OCCURED=TimeOut occurred
+ERR_04170_TIMEOUT_OCCURED=TimeOut occurred when calling function {0}
 ERR_04171_CANNOT_PARSE_MATCHED_DN=Could not parse matchedDn while transforming Codec value to Internal: {0}
 ERR_04172_KEYSTORE_INIT_FAILURE=Keystore initialisation failure
 ERR_04173_ALGORITHM_NOT_FOUND=Not TrustManagerFactory found for algorithm ''{0}''
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
index 737721023..140e33833 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/EntryCursorImpl.java
@@ -100,7 +100,7 @@ public class EntryCursorImpl extends AbstractCursor<Entry> implements EntryCurso
 
                 if ( response == null )
                 {
-                    throw new LdapException( LdapNetworkConnection.TIME_OUT_ERROR );
+                    throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "next()" ) );
                 }
 
                 messageId = response.getMessageId();
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 ce316c50a..b9b9be207 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
@@ -281,8 +281,6 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
     private CompletableFuture<Integer> connectionCloseFuture = new CompletableFuture<>(); 
     
     // ~~~~~~~~~~~~~~~~~ common error messages ~~~~~~~~~~~~~~~~~~~~~~~~~~
-    static final String TIME_OUT_ERROR = I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED );
-
     static final String NO_RESPONSE_ERROR = I18n.err( I18n.ERR_04169_RESPONSE_QUEUE_EMPTIED );
     
    //------------------------- The constructors --------------------------//
@@ -817,10 +815,10 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
         // We didn't received anything : this is an error
         if ( LOG.isErrorEnabled() )
         {
-            LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Connect" ) );
+            LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Close" ) );
         }
 
-        throw new LdapException( TIME_OUT_ERROR );
+        throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Close" ) );
     }
     
     
@@ -852,7 +850,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                 // if there is no cause assume timeout
                 if ( cause == null )
                 {
-                    throw new LdapException( TIME_OUT_ERROR );
+                    throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "checkSecured" ) );
                 }
 
                 throw new LdapTlsHandshakeException( I18n.err( I18n.ERR_04120_TLS_HANDSHAKE_ERROR ), cause );
@@ -1198,7 +1196,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Add" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Add" ) );
             }
 
             if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1593,7 +1591,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind Simple" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1754,7 +1752,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL Plain" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1826,7 +1824,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1934,7 +1932,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL CramlMD5" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -2006,7 +2004,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL plain" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -2092,7 +2090,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL Digest MD5" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -2164,7 +2162,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL GSSAPI" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -2236,7 +2234,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL External" ) );
             }
 
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -3312,7 +3310,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Modify" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Modify" ) );
             }
 
             if ( modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -3708,7 +3706,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "ModifyDn" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "ModifyDN" ) );
             }
 
             if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -3930,7 +3928,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Delete" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Delete" ) );
             }
 
             if ( delResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -4142,7 +4140,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Compare" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Compare" ) );
             }
 
             if ( compareResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -4341,7 +4339,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                     LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Extended" ) );
                 }
                 
-                throw new LdapException( TIME_OUT_ERROR );
+                throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Extended" ) );
             }
 
             if ( response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -5263,7 +5261,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                         LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                     }
                     
-                    throw new LdapException( TIME_OUT_ERROR );
+                    throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL" ) );
                 }
 
                 result = bindResponse.getLdapResult().getResultCode();
@@ -5292,7 +5290,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                         LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                     }
                     
-                    throw new LdapException( TIME_OUT_ERROR );
+                    throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL" ) );
                 }
 
                 result = bindResponse.getLdapResult().getResultCode();
@@ -5330,7 +5328,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                             LOG.error( I18n.err( I18n.ERR_04112_OP_FAILED_TIMEOUT, "Bind" ) );
                         }
                         
-                        throw new LdapException( TIME_OUT_ERROR );
+                        throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "Bind SASL" ) );
                     }
 
                     result = bindResponse.getLdapResult().getResultCode();
@@ -5416,7 +5414,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
             LOG.error( I18n.err( I18n.ERR_04119_TIMEOUT ) );
         }
         
-        throw new LdapException( TIME_OUT_ERROR );
+        throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "write" ) );
     }
 
 
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
index 0a2298563..549f26e7c 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
@@ -39,7 +39,6 @@ import org.apache.directory.api.ldap.model.message.Response;
 import org.apache.directory.api.ldap.model.message.SearchResultDone;
 import org.apache.directory.api.ldap.model.message.SearchResultEntry;
 import org.apache.directory.api.ldap.model.message.SearchResultReference;
-import org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -145,7 +144,7 @@ public class SearchCursorImpl extends AbstractCursor<Response> implements Search
         {
             future.cancel( true );
 
-            throw new LdapConnectionTimeOutException( LdapNetworkConnection.TIME_OUT_ERROR );
+            throw new LdapException( I18n.err( I18n.ERR_04170_TIMEOUT_OCCURED, "next()" ) );
         }
 
         done = response instanceof SearchResultDone;