directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <>
Subject [jira] [Commented] (DIRAPI-342) Unbind breaks connection
Date Mon, 03 Jun 2019 23:50:00 GMT


Emmanuel Lecharny commented on DIRAPI-342:

Ok, some progress...

The {{tryConnect()}} metyhod has been redesigned. We were doing useless things, like having
a {{retry}} loop that was never activated. This has been removed. The {{timeout}}, if reached,
now generates an exception.
Regarding my previous comment, the connection is actually set to connected when the {{sessionCreated}}
event is called :

    private static class TailFilter extends IoFilterAdapter {
        public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception
            try {
            } finally {
                // Notify the related future.
                ConnectFuture future = (ConnectFuture) session.removeAttribute(SESSION_CREATED_FUTURE);

                if (future != null) {
                    future.setSession(session);  <---- Here

So this is handled by MINA, in the last filter before it hits the LDAP API handler. We are
good to go.

I have also integrated some of Stefan's changes, typically, the {{connected}} flag has been
removed, it's useless.

Otherwise, the {{ldapSession}} variable in {{LdapNetworkConnection}} has been renamed to {{ioSession}}
for clarity: a LDAP session is semantically very different from a {{IoSession}}. For instance,
you can have many different {{LdapSession}} over a single {{IoSession}} (not at the same time
though... You need to bind with different creds to switch from one {{LdapSession}} to the
next one).

In order to 'link' the session closure call to the {{sessionClosed}} event, I'm using a {{CountdownLatch}}
as I said before, but a {{CompletableFuture}} might also be an option. It's semantically better,
evn if it does the exact same thing. The difference is that we don't need to manipulate the
counter and decrease it through a call to {{countdown}}, it's enough to cancel the future.
Note that it's a Java 8 class. I'll check to see if it's the right approach.

In any case, it's going to be much better than what it was, even if not perfect. Working in
a async environment is clearly making things way harder...

> Unbind breaks connection
> ------------------------
>                 Key: DIRAPI-342
>                 URL:
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 2.0.0.AM2
>            Reporter: Stefan Seelmann
>            Priority: Major
>             Fix For: 2.0.0.AM4, 2.0.0
>         Attachments: latch.patch
> The DelegatedAuthIT/DelegatedAuthOverSslIT/DelegatedAuthOverTlsIT tests fail randomly
(I try to stabilize tests on Windows, but also happens on Jenkins). They all do multiple bind()
and unbind() on the same connection, it seems the unbind() is the reason.
> A simple test to reproduce the problem (on Linux):
> {code}
>     @Test
>     public void testSimpleBindAndUnbindLoop() throws Exception
>     {
>         try ( LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME,
>             getLdapServer().getPort() ) )
>         {
>             for ( int i = 0; i < 10000; i++ )
>             {
>                 System.out.println( i );
>                 connection.bind( "uid=admin,ou=system", "secret" );
>                 assertTrue( connection.isAuthenticated() );
>                 connection.unBind();
>                 assertFalse( connection.isAuthenticated() );
>                 // Thread.sleep( 10L );
>             }
>         }
>     }
> {code}
> Without the unbind() or when sleeping for 10ms it works fine.
> Otherwise I saw 3 different errors:
> {code}
Cannot connect on the server, the connection is invalid
> 	at
> 	at
> 	at
> 	at
> 	at
> {code}
> {code}
The response queue has been emptied, no response was found.
> 	at
> 	at
> 	at
> Caused by: ERR_04170_TIMEOUT_OCCURED
TimeOut occurred
> 	at
> {code}
> {code}
The server will disconnect!
> 	at
> 	at
> 	at
> 	at
> {code}

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message