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/09/03 20:29:14 UTC

(directory-ldap-api) branch master updated: o Avoid throwing an IllegalArgumentException when a wrong Integer is passed as an argument o Check that a DecoderException is thrown

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 39790322e o Avoid throwing an IllegalArgumentException when a wrong Integer is passed as an argument o Check that a DecoderException is thrown
39790322e is described below

commit 39790322e823d4c9d698264919d4eea9f3aad171
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Thu Sep 3 22:29:09 2026 +0200

    o Avoid throwing an IllegalArgumentException when a wrong Integer is
    passed as an argument
    o Check that a DecoderException is thrown
---
 .../org/apache/directory/api/asn1/actions/AbstractReadInteger.java  | 6 +++---
 .../api/ldap/codec/controls/sort/SortResponseControlTest.java       | 3 ++-
 .../api/ldap/extras/controls/vlv/VLVResponseControlTest.java        | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java
index f370b9c02..f907e95da 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/actions/AbstractReadInteger.java
@@ -122,13 +122,13 @@ public abstract class AbstractReadInteger<E extends Asn1Container> extends Gramm
 
             setIntegerValue( number, container );
         }
-        catch ( IntegerDecoderException ide )
+        catch ( IllegalArgumentException | IntegerDecoderException e )
         {
-            LOG.error( I18n.err( I18n.ERR_01102_INVALID_INTEGER, Strings.dumpBytes( value.getData() ), ide
+            LOG.error( I18n.err( I18n.ERR_01102_INVALID_INTEGER, Strings.dumpBytes( value.getData() ), e
                 .getLocalizedMessage() ) );
 
             // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( ide.getMessage(), ide );
+            throw new DecoderException( e.getMessage(), e );
         }
     }
 }
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java
index 41263034e..36c7384f3 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java
@@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.nio.ByteBuffer;
 
+import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.util.Asn1Buffer;
 import org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest;
 import org.apache.directory.api.ldap.model.message.controls.SortResponse;
@@ -116,7 +117,7 @@ public class SortResponseControlTest extends AbstractCodecServiceTest
             get( SortResponse.OID );
         SortResponse control = factory.newControl();
 
-        assertThrows( IllegalArgumentException.class, ( ) ->
+        assertThrows( DecoderException.class, ( ) ->
         {
             factory.decodeValue( control, bb.array() );
         } );
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/vlv/VLVResponseControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/vlv/VLVResponseControlTest.java
index 75935a7cd..70f80d15a 100644
--- a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/vlv/VLVResponseControlTest.java
+++ b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/vlv/VLVResponseControlTest.java
@@ -186,7 +186,7 @@ public class VLVResponseControlTest
                   0x02, 0x01, 0x01,     //    targetPosition    INTEGER (0 .. maxInt),
                   0x02, 0x01, 0x01,     //    contentCount     INTEGER (0 .. maxInt),
                   0x0A, 0x01, 0x11,     //    virtualListViewResult ENUMERATED {
-                                        //                   success (0),
+                                        //                   unknown  (17),
                   0x04, 0x04,           //    contextID     OCTET STRING OPTIONAL }
                     'a', 'b', 'c', 'd'
             } );
@@ -198,7 +198,7 @@ public class VLVResponseControlTest
             get( VirtualListViewResponse.OID );
         VirtualListViewResponse virtualListView = factory.newControl();
 
-        assertThrows( IllegalArgumentException.class, ( ) ->
+        assertThrows( DecoderException.class, ( ) ->
         {
             factory.decodeValue( virtualListView, bb.array() );
         } );