if (LOG.isWarnEnabled()) LOG.warn("Read operation on socket failed" , e);
if (LOG.isTraceEnabled()) LOG.trace("Read operation on socket failed" , e);
      public void run()      {         while (true)         {  // m_s can be closed by the management thread            int events;            try            {               events = SELECTOR.select();            } catch (IOException e)            {               if (LOG.isWarnEnabled())                  LOG.warn("Select operation on socket failed", e);               continue;   // Give up this time            } catch (ClosedSelectorException e)            {               if (LOG.isWarnEnabled())                  LOG.warn("Select operation on socket failed" , e);               return;     // Selector gets closed, thread stops            }            if (events > 0)            {   // there are read-ready channels               Set readyKeys = SELECTOR.selectedKeys();               for (Iterator i = readyKeys.iterator(); i.hasNext();)               {                  SelectionKey key = (SelectionKey) i.next();                  i.remove();                  // Do partial read and handle call back                  Connection conn = (Connection) key.attachment();                  try                  {                     if (conn.getSocketChannel().isOpen())                        readOnce(conn);                     else                     {  // socket connection is already closed, clean up connection state                        conn.closed();                     }                  } catch (IOException e)                  {                     if (LOG.isWarnEnabled()) LOG.warn("Read operation on socket failed" , e);                     // The connection must be bad, cancel the key, close socket, then                     // remove it from table!                     key.cancel();                     conn.destroy();                     conn.closed();                  }               }            }            // Now we look at the connection queue to get any new connections added            Object o;            try            {               o = QUEUE.poll(0); // get a connection            } catch (InterruptedException e)            {               if (LOG.isInfoEnabled()) LOG.info("Thread ("+Thread.currentThread().getName() +") was interrupted while polling queue" ,e);               // We must give up               continue;            }            if (null == o)               continue;            if (o instanceof Shutdown) {     // shutdown command?               try {                  SELECTOR.close();               } catch(IOException e) {                  if (LOG.isInfoEnabled()) LOG.info("Read selector close operation failed" , e);               }               return;                       // stop reading            }            Connection conn = (Connection) o;// must be a new connection            SocketChannel sc = conn.getSocketChannel();            try            {               sc.register(SELECTOR, SelectionKey.OP_READ, conn);            } catch (ClosedChannelException e)            {               if (LOG.isInfoEnabled()) LOG.info("Socket channel was closed while we were trying to register it to selector" , e);               // Channel becomes bad. The connection must be bad,               // close socket, then remove it from table!               conn.destroy();               conn.closed();            }         }   // end of the while true loop      }