Skip to content
Permalink
Browse files
Patch for DIRAPI-358
  • Loading branch information
emmanuel lecharny committed Nov 17, 2020
1 parent 8d16cfe commit c037f94331a5f0213e9a321797d390e0f8d89ab2
Showing 1 changed file with 53 additions and 35 deletions.
@@ -702,6 +702,11 @@ public ConnectFuture tryConnect() throws LdapException
// It may be an exception, or a timeout
Throwable connectionException = connectionFuture.getException();

if ( ( connector != null ) && !connector.isDisposing() && !connector.isDisposed() )
{
connector.dispose();
}

connector = null;

if ( connectionException == null )
@@ -943,46 +948,59 @@ public boolean connect() throws LdapException
return true;
}

// Create the connector if needed
if ( connector == null )
{
createConnector();
}

// And create the connection future
ConnectFuture connectionFuture = tryConnect();

// Check if we are good to go
if ( !connectionFuture.isConnected() )
try
{
// Release the latch
connectionCloseFuture.cancel( true );
// Create the connector if needed
if ( connector == null )
{
createConnector();
}

// And create the connection future
ConnectFuture connectionFuture = tryConnect();

// Check if we are good to go
if ( !connectionFuture.isConnected() )
{
// Release the latch
connectionCloseFuture.cancel( true );

close( connectionFuture );
}

// Check if we are secured if requested
if ( config.isUseSsl() )
{
checkSecured( connectionFuture );
}

// Add a listener to close the session in the session.
setCloseListener( connectionFuture );

// Get back the session
ioSession = connectionFuture.getSession();

// Store the container into the session if we don't have one
setBinaryDetector();

// Initialize the MessageId
messageId.set( 0 );

close( connectionFuture );
connectionCloseFuture = new CompletableFuture<>();

// And return
return true;
}

// Check if we are secured if requested
if ( config.isUseSsl() )
catch ( Exception e )
{
checkSecured( connectionFuture );
}

// Add a listener to close the session in the session.
setCloseListener( connectionFuture );

// Get back the session
ioSession = connectionFuture.getSession();

// Store the container into the session if we don't have one
setBinaryDetector();

// Initialize the MessageId
messageId.set( 0 );

connectionCloseFuture = new CompletableFuture<>();
if ( ( connector != null ) && !connector.isDisposing() && !connector.isDisposed() )
{
connector.dispose();
connector = null;
}

// And return
return true;
throw e;
}
}


0 comments on commit c037f94

Please sign in to comment.