question: private void processSelectedKeysOptimized ( SelectionKey [ ] keys ) throws ClosedByInterruptException { for ( int i = 0 ; ; i ++ ) { final SelectionKey key = keys [ i ] ; if ( key == null ) break ; keys [ i ] = null ; if ( ! key . isValid ( ) ) continue ; GridSelectorNioSessionImpl ses = ( GridSelectorNioSessionImpl ) key . attachment ( ) ; assert ses != null ; try { if ( key . isReadable ( ) ) processRead ( key ) ; if ( key . isValid ( ) && key . isWritable ( ) ) processWrite ( key ) ; } catch ( ClosedByInterruptException e ) { throw e ; } catch ( Exception e ) { U . warn ( log , "Failed to process selector key (will close): " + ses , e ) ; close ( ses , new GridNioException ( e ) ) ; } } }
target:  Processes keys selected by a selector.