/** * Cleans up the contents of the selector, closing any server socket channels that might be * associated with it. Any connections that might have been established through those channels * should not be impacted. */ private void cleanUpSelector() { try { for (SelectionKey key : selector.keys()) { try { key.cancel(); } catch (Exception e) { logger.traceException(e); } try { key.channel().close(); } catch (Exception e) { logger.traceException(e); } } } catch (Exception e) { logger.traceException(e); } }