directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <>
Subject [jira] [Commented] (DIRAPI-140) Test ClientSearchRequestTest.testSubDn() fails
Date Tue, 21 May 2013 11:55:16 GMT


Emmanuel Lecharny commented on DIRAPI-140:

Ok, I have a better understanding on what's going on.

On the server, when we process a searchRequest, we loop on the created cursor until we have
no more elements to return. This is done by the SearchRequestHandler.writeResults() method

        while ( ( count < sizeLimit ) && )

If, for any reason, the abandonRequest is received and processed at the very same time, what
will happen is that the cursor will be closed. We do check this condition :

    public boolean next() throws LdapException, CursorException, IOException
        checkNotClosed( "next()" );

    public final void checkNotClosed( String operation ) throws CursorClosedException


    public void checkNotClosed() throws CursorClosedException
        // lack of synchronization may cause pass but eventually it will work
        if ( closed )
            throw new CursorClosedException( cause.getMessage() );

So basically, we get an exception instead of something easier to handle.

It's not happening very often, but still, with 1000 loop, it's almost guaranteed to happen.

As a side effect, we generate an exception which has no cause, which leads to a NPE later
in the SearchRequestHandler.handleException() method :

    public void handleException( LdapSession session, ResultResponseRequest req, Exception
e )
        LdapResult result = req.getResultResponse().getLdapResult();

         * Set the result code or guess the best option.
        ResultCodeEnum code;

        if ( e instanceof CursorClosedException )
            e = ( Exception ) ( ( CursorClosedException ) e ).getCause();  <<<--------------
Bad ! We should not overwrite the exception parameter here...

Here, e becomes null and it shows in the trace because of :

        String msg = code.toString() + ": failed for " + req + ": " + e.getLocalizedMessage();
 <<<--- NPE

In any case, we should not throw an exception when the cursor is simply closed because of
an abandon request, we should instead return false to a call to

There is a bit of work to fix that, but it's not really complicated.

> Test ClientSearchRequestTest.testSubDn() fails
> ----------------------------------------------
>                 Key: DIRAPI-140
>                 URL:
>             Project: Directory Client API
>          Issue Type: Bug
>         Environment: Apache Maven 3.0.5 (rNON-CANONICAL_2013-02-25_10-23_root; 2013-02-25
> Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "3.9.2-1-arch", arch: "amd64", family: "unix"
>            Reporter: Stefan Seelmann
> In trunk the test ClientSearchRequestTest.testSubDn (module ldap-client-test) fails quite
often. When adding a for loop around the test code it fails after 1-10 executions. The first
search works always, but the second search which uses the SearchRequest object sometimes doesn't
contain a result and is false. Please note that I'm not sure if that is
a pb in client or in the server.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message