docs: private void rebuildSelector() {
  
          final Selector oldSelector = this.selector;
          final Selector newSelector;
  
          if (oldSelector == null) {
              return;
          }
  
          try {
              newSelector = openSelector();
          } catch (Exception e) {
              LOGGER.warn("Failed to create a new Selector.", e);
              return;
          }
  
          // 注册所有的channels到新的Selector.
          int nChannels = 0;
          for (; ; ) {
              try {
                  for (SelectionKey key : oldSelector.keys()) {
                      Object a = key.attachment();
                      try {
                          if (key.channel().keyFor(newSelector) != null) {
                              continue;
                          }
  
                          int interestOps = key.interestOps();
                          key.cancel();
                          key.channel().register(newSelector, interestOps, a);
                          nChannels++;
                      } catch (Exception e) {
                          LOGGER.warn("Failed to re-register a Channel to the new Selector.", e);
                      }
                  }
              } catch (ConcurrentModificationException e) {
                  // Probably due to concurrent modification of the key set.
                  continue;
              }
  
              break;
          }
  
          selector = newSelector;
  
          try {
              // time to close the old selector as everything else is registered to the new one
              oldSelector.close();
          } catch (Throwable t) {
              if (LOGGER.isWarnEnabled()) {
                  LOGGER.warn("Failed to close the old Selector.", t);
              }
          }
  
          LOGGER.info("Migrated " + nChannels + " channel(s) to the new Selector.");
      }