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 2020/05/25 05:25:31 UTC
[directory-ldap-api] branch master updated: o Catch more than just
LdapException when feeding an Entry o Improved the error message for when
an attribute is syntactically incorrect o Added the exceptionCaught()
method in LdapConnection,
to get a precise information about any potential error that could have
occurred That solves DIRAPI-359
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 253211c o Catch more than just LdapException when feeding an Entry o Improved the error message for when an attribute is syntactically incorrect o Added the exceptionCaught() method in LdapConnection, to get a precise information about any potential error that could have occurred That solves DIRAPI-359
253211c is described below
commit 253211caad1c53e47687137fe36e009d61b1b623
Author: emmanuel lecharny <em...@busit.com>
AuthorDate: Mon May 25 07:25:25 2020 +0200
o Catch more than just LdapException when feeding an Entry
o Improved the error message for when an attribute is syntactically
incorrect
o Added the exceptionCaught() method in LdapConnection, to get a precise
information about any potential error that could have occurred
That solves DIRAPI-359
---
.../resources/org/apache/directory/api/i18n/errors.properties | 2 +-
.../org/apache/directory/ldap/client/api/LdapConnection.java | 9 +++++++++
.../directory/ldap/client/api/LdapConnectionWrapper.java | 9 +++++++++
.../directory/ldap/client/api/LdapNetworkConnection.java | 10 ++++++++++
.../org/apache/directory/ldap/client/api/QuirkySchemaTest.java | 7 +++++++
.../apache/directory/api/ldap/model/entry/DefaultEntry.java | 2 +-
.../java/org/apache/directory/api/ldap/model/entry/Value.java | 4 ++--
7 files changed, 39 insertions(+), 4 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 b72ab87..dc614af 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
@@ -526,7 +526,7 @@ ERR_13243_ENTRY_IMMUTABLE_CANT_DESERIALIZE=Cannot deserialize the entry {0} is i
ERR_13244_ID_AT_NOT_COMPATIBLE=ID ''{0}'' and AttributeType ''{1}'' are not compatible
ERR_13245_AT_PARAMETER_NULL=The AttributeType parameter should not be null
ERR_13246_INVALID_VALUE_PER_SYNTAX=Invalid upValue per syntax
-ERR_13247_INVALID_VALUE_CANT_NORMALIZE=Invalid upValue, it can''t be normalized
+ERR_13247_INVALID_VALUE_CANT_NORMALIZE=Invalid upValue ''{0}'', it can''t be normalized
ERR_13248_CANNOT_READ_ENTRY=Cannot read an entry
ERR_13249_NO_COMPARATOR_FOR_AT=No comparator for attributeType {0}
ERR_13250_VALUE_MISSING_AT_THE_END=A value is missing at the end
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
index d102119..d9a23b8 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
@@ -92,6 +92,15 @@ public interface LdapConnection extends Closeable
* @throws LdapException if some error occurred
*/
boolean connect() throws LdapException;
+
+
+ /**
+ * tell if an exception was caught while processing the request or a response.
+ *
+ * @return The exception if there was one thrown while processing a
+ * request or a response
+ */
+ Throwable exceptionCaught();
/**
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
index e132756..4ec11ec 100755
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
@@ -119,6 +119,15 @@ public class LdapConnectionWrapper implements LdapConnection, Wrapper<LdapConnec
return connection.connect();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public Throwable exceptionCaught()
+ {
+ return connection.exceptionCaught();
+ }
+
/**
* {@inheritDoc}
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 8349d74..a3969c8 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
@@ -564,6 +564,16 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public Throwable exceptionCaught()
+ {
+ return ( Throwable ) ioSession.getAttribute( EXCEPTION_KEY );
+ }
+
+
+ /**
* Check that a session is valid, ie we can send requests to the
* server
*
diff --git a/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java b/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java
index 089fc7c..01adb90 100644
--- a/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java
+++ b/ldap/client/api/src/test/java/org/apache/directory/ldap/client/api/QuirkySchemaTest.java
@@ -389,7 +389,14 @@ public class QuirkySchemaTest
{
return false;
}
+
+ @Override
+ public Throwable exceptionCaught()
+ {
+ return null;
+ }
+
@Override
public List<String> getSupportedControls() throws LdapException
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
index 218d552..e363e7c 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
@@ -326,7 +326,7 @@ public final class DefaultEntry implements Entry
// And store it
add( serverAttribute );
}
- catch ( LdapException ne )
+ catch ( Exception ne )
{
// Just log a warning
if ( LOG.isWarnEnabled() )
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
index 25d8eb3..9a66844 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/Value.java
@@ -271,7 +271,7 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
catch ( LdapException le )
{
LOG.error( le.getMessage() );
- throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE ) );
+ throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE, upValue ) );
}
if ( !attributeType.isRelaxed() )
@@ -376,7 +376,7 @@ public class Value implements Cloneable, Externalizable, Comparable<Value>
catch ( LdapException le )
{
LOG.error( le.getMessage() );
- throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE ) );
+ throw new IllegalArgumentException( I18n.err( I18n.ERR_13247_INVALID_VALUE_CANT_NORMALIZE, upValue ) );
}
// Check the normValue