From 3f0cfc76e1df2e7dc5986b58e645c04118025229 Mon Sep 17 00:00:00 2001 From: Mikko Kortelainen Date: Tue, 14 May 2024 16:48:43 +0300 Subject: [PATCH] catch CancelledKeyException when debug logging in EventLoop (#166) --- .../teragrep/rlp_03/eventloop/EventLoop.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/teragrep/rlp_03/eventloop/EventLoop.java b/src/main/java/com/teragrep/rlp_03/eventloop/EventLoop.java index 4d1cee61..3f71c785 100644 --- a/src/main/java/com/teragrep/rlp_03/eventloop/EventLoop.java +++ b/src/main/java/com/teragrep/rlp_03/eventloop/EventLoop.java @@ -125,16 +125,15 @@ public void poll() throws IOException { Set selectionKeys = selector.selectedKeys(); LOGGER.debug("selectionKeys <{}> ", selectionKeys); for (SelectionKey selectionKey : selectionKeys) { - if (LOGGER.isDebugEnabled()) { - LOGGER - .debug( - "selectionKey <{}>: isValid <{}>, isConnectable <{}>, isAcceptable <{}>, isReadable <{}>, isWritable <{}>", - selectionKey, selectionKey.isValid(), selectionKey.isConnectable(), - selectionKey.isAcceptable(), selectionKey.isReadable(), selectionKey.isWritable() - ); - } - try { + if (LOGGER.isDebugEnabled()) { + LOGGER + .debug( + "selectionKey <{}>: isValid <{}>, isConnectable <{}>, isAcceptable <{}>, isReadable <{}>, isWritable <{}>", + selectionKey, selectionKey.isValid(), selectionKey.isConnectable(), + selectionKey.isAcceptable(), selectionKey.isReadable(), selectionKey.isWritable() + ); + } if (selectionKey.isAcceptable()) { // ListenContext ListenContext listenContext = (ListenContext) selectionKey.attachment();