directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Using ApacheDS api SearchCursor , getting Asn1Decoder warning to logs / console..
Date Fri, 07 Dec 2012 17:49:19 GMT
Ok thanks for the detailed clarification! 

-----Original Message-----
From: Emmanuel Lécharny [] 
Sent: Friday, December 07, 2012 11:22 AM
Subject: Re: Using ApacheDS api SearchCursor , getting Asn1Decoder warning to logs / console..

Le 12/7/12 4:57 PM, a écrit :
> Hi,   We've starting moving some of our JNDI code to the ApacheDS API. The method below
is used to get an Array of entries.
> When we close the cursor ( I think), we see the following log message.
The PDU has been fully decoded but there are still bytes in the buffer.
> We get the results we want but is there something else we need to do with the cursor
to avoid the message?  Thanks.
This is a wrong message. It should be at level INFO at best.

What happens is that when the client receives some data from the server (whatever server it
can be), it will decode those data and produce LDAP messages. So far, so good. The thing is
that we may have received more than one LDAP message in a simple socket read, and the decoder
detect that. Here are the two methods that handle the decoding :

1) the main loop, decoding LDAP message :

        List<Message> decodedMessages = new ArrayList<Message>();
        ByteBuffer buf = in.buf();

        decode( buf, messageContainer, decodedMessages );

        for ( Message message : decodedMessages )
            out.write( message );

It calls the decode() message with a ByteBuffer that might contain more than one message,
and accumulate the messages in a list that will be processed later :

    private void decode( ByteBuffer buffer, LdapMessageContainer<MessageDecorator<?
extends Message>> messageContainer,
        List<Message> decodedMessages ) throws DecoderException
        while ( buffer.hasRemaining() )
                asn1Decoder.decode( buffer, messageContainer );

                if ( messageContainer.getState() == TLVStateEnum.PDU_DECODED )

                    Message message = messageContainer.getMessage();

                    decodedMessages.add( message );


The Asn1Decoder process one single message, and when done, if there is still some data in
the buffer, generates some Warning :

    public void decode( ByteBuffer stream, Asn1Container container ) throws DecoderException
        boolean hasRemaining = stream.hasRemaining();

        while ( hasRemaining )
                case PDU_DECODED:
                    // We have to deal with the case where there are
                    // more bytes in the buffer, but the PDU has been decoded.
                    LOG.warn( I18n.err(

                    hasRemaining = false;


Bottom line, I think I will move the Warning to a Debug.

Emmanuel Lécharny 

View raw message