question: @ Override protected void registerNewSelector ( ) throws IOException { synchronized ( selector ) { Set < SelectionKey > keys = selector . keys ( ) ; Selector newSelector = null ; if ( selectorProvider == null ) { newSelector = Selector . open ( ) ; } else { newSelector = selectorProvider . openSelector ( ) ; } for ( SelectionKey key : keys ) { SelectableChannel ch = key . channel ( ) ; NioSession session = ( NioSession ) key . attachment ( ) ; SelectionKey newKey = ch . register ( newSelector , key . interestOps ( ) , session ) ; session . setSelectionKey ( newKey ) ; } selector . close ( ) ; selector = newSelector ; } }
target:  In the case we are using the java select() method, this method is used to trash the buggy selector and create a new one, registering all the sockets on it.