@ Handler @ SuppressWarnings ( "PMD.DataflowAnomalyAnalysis" ) public void onClose ( Close event ) throws IOException , InterruptedException { boolean subOnly = true ; for ( Channel channel : event . channels ( ) ) { if ( channel instanceof TcpChannelImpl ) { if ( channels . contains ( channel ) ) { ( ( TcpChannelImpl ) channel ) . close ( ) ; } } else { subOnly = false ; } } if ( subOnly || ! serverSocketChannel . isOpen ( ) ) { // Closed already fire ( new Closed ( ) ) ; return ; } synchronized ( channels ) { closing = true ; // Copy to avoid concurrent modification exception Set < TcpChannelImpl > conns = new HashSet <> ( channels ) ; for ( TcpChannelImpl conn : conns ) { conn . close ( ) ; } while ( ! channels . isEmpty ( ) ) { channels . wait ( ) ; } } serverSocketChannel . close ( ) ; purger . interrupt ( ) ; closing = false ; fire ( new Closed ( ) ) ; }
Shuts down the server or one of the connections to the server .