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 2024/10/28 17:32:10 UTC
(directory-ldap-api) branch master updated: Fix for DIRAPI-410 and DIRAPI-409
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 63fef9b65 Fix for DIRAPI-410 and DIRAPI-409
new 84de0e57d Merge remote-tracking branch 'refs/remotes/origin/master'
63fef9b65 is described below
commit 63fef9b65a3f336cedd64cabdbf9b875c0ef836b
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Mon Oct 28 18:31:34 2024 +0100
Fix for DIRAPI-410 and DIRAPI-409
---
i18n/src/main/java/org/apache/directory/api/i18n/I18n.java | 2 +-
.../resources/org/apache/directory/api/i18n/errors.properties | 2 +-
.../org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java | 9 ++++++++-
.../main/java/org/apache/directory/api/ldap/model/name/Ava.java | 7 ++++++-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
index 84c7817b9..bab096b9f 100644
--- a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
+++ b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
@@ -415,7 +415,7 @@ public enum I18n
ERR_9300_UNEXPECTED_SYNCINFO( "ERR_9300_UNEXPECTED_SYNCINFO" ),
// api-ldap-extras-sp 10000-10999
- // None
+ ERR_10000_EMPTY_SP_CLASS( "ERR_10000_EMPTY_SP_CLASS" ),
// api-ldap-extras-trigger 11000-11999
ERR_11000_TRIGGER_SPECIFICATION_INIT_WITH_NULL( "ERR_11000_TRIGGER_SPECIFICATION_INIT_WITH_NULL" ),
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 9e818b95b..9b1ec6496 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
@@ -406,7 +406,7 @@ ERR_9200_INTERGER_DECODING_FAILURE=Failed to decode INTEGER: {0}
ERR_9300_UNEXPECTED_SYNCINFO=Unexpected SynchronizationInfo: {0}
# api-ldap-extras-sp 10000-10999
-# none
+ERR_10000_EMPTY_SP_CLASS=The stored procedure class file {0} is empy.
# api-ldap-extras-trigger 11000-11999
ERR_11000_TRIGGER_SPECIFICATION_INIT_WITH_NULL=TriggerSpecification cannot be initialized with any NULL argument.
diff --git a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
index 287640f14..949651b48 100644
--- a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
+++ b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
@@ -37,6 +37,7 @@ import javax.naming.ldap.ExtendedResponse;
import javax.naming.ldap.LdapContext;
import org.apache.commons.lang3.SerializationUtils;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
import org.apache.directory.api.ldap.extras.extended.storedProcedure.StoredProcedureRequestImpl;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -83,7 +84,13 @@ public final class JavaStoredProcUtils
File file = new File( url.toURI() );
int size = ( int ) file.length();
byte[] buf = new byte[size];
- in.read( buf );
+ int nbRead = in.read( buf );
+
+ if ( nbRead == -1 )
+ {
+ NamingException ne = new NamingException( I18n.err( I18n.ERR_10000_EMPTY_SP_CLASS, url.toURI() ) );
+ throw ne;
+ }
return buf;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
index bd88557b3..e53f0adb5 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
@@ -1210,6 +1210,7 @@ public class Ava implements Externalizable, Cloneable, Comparable<Ava>
out.writeBoolean( false );
}
+ // Useless... See #readExternal
boolean isHR = value.isHumanReadable();
out.writeBoolean( isHR );
@@ -1273,7 +1274,11 @@ public class Ava implements Externalizable, Cloneable, Comparable<Ava>
}
}
- in.readBoolean();
+ // We need to read this useless value because we are writing in in the writeExternal meythod
+ // The problem is that when a Ldap Server uses this class to read back entries from the database
+ // it will expect to read this extra boolean, so removing it without migrating the database will
+ // break it...
+ boolean isHr = in.readBoolean();
value = Value.deserialize( attributeType, in );