log.warn( "Failed to sent NoD.", e );
WriteFuture future = ( WriteFuture ) i.next(); future.join( 1000 ); ( ( IoSession ) sessionIt.next() ).close();
    private void stopLDAP0( Service service )    {        if ( ldapService != null )        {            try            {                // we should unbind the service before we begin sending the notice                 // of disconnect so new connections are not formed while we process                List writeFutures = new ArrayList();                IoAcceptor acceptor = minaRegistry.getAcceptor( service.getTransportType() );                // If the socket has already been unbound as with a successful                 // GracefulShutdownRequest then this will complain that the service                // is not bound - this is ok because the GracefulShutdown has already                // sent notices to to the existing active sessions                List sessions = null;                try                {                    sessions = new ArrayList( acceptor.getManagedSessions( service.getAddress() ) );                }                catch ( IllegalArgumentException e )                {                    log.warn( "Seems like the LDAP service " + service + " has already been unbound." );                    return;                }                minaRegistry.unbind( service );                if ( log.isInfoEnabled() )                {                    log.info( "Unbind of " + service.getName() + " Service complete: " + ldapService );                    log.info( "Sending notice of disconnect to existing clients sessions." );                }                // Send Notification of Disconnection messages to all connected clients.                if ( sessions != null )                {                    for ( Iterator i = sessions.iterator(); i.hasNext(); )                    {                        IoSession session = ( IoSession ) i.next();                        writeFutures.add( session.write( NoticeOfDisconnect.UNAVAILABLE ) );                    }                }                // And close the connections when the NoDs are sent.                Iterator sessionIt = sessions.iterator();                for ( Iterator i = writeFutures.iterator(); i.hasNext(); )                {                    WriteFuture future = ( WriteFuture ) i.next();                    future.join( 1000 );                    ( ( IoSession ) sessionIt.next() ).close();                }            }            catch ( Exception e )            {                log.warn( "Failed to sent NoD.", e );            }        }    }