diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java index 1deab30aa7..c9cb838ed8 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java @@ -390,19 +390,24 @@ class EpollEventLoop extends SingleThreadEventLoop { //increase the size of the array as we needed the whole space for the events events.increase(); } + } catch (Error e) { + throw (Error) e; } catch (Throwable t) { handleLoopException(t); - } - // Always handle shutdown even if the loop processing threw an exception. - try { - if (isShuttingDown()) { - closeAll(); - if (confirmShutdown()) { - break; + } finally { + // Always handle shutdown even if the loop processing threw an exception. + try { + if (isShuttingDown()) { + closeAll(); + if (confirmShutdown()) { + break; + } } + } catch (Error e) { + throw (Error) e; + } catch (Throwable t) { + handleLoopException(t); } - } catch (Throwable t) { - handleLoopException(t); } } } diff --git a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventLoop.java b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventLoop.java index 51c3b2f16d..6791768a7d 100644 --- a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventLoop.java +++ b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventLoop.java @@ -297,19 +297,24 @@ final class KQueueEventLoop extends SingleThreadEventLoop { //increase the size of the array as we needed the whole space for the events eventList.realloc(false); } + } catch (Error e) { + throw (Error) e; } catch (Throwable t) { handleLoopException(t); - } - // Always handle shutdown even if the loop processing threw an exception. - try { - if (isShuttingDown()) { - closeAll(); - if (confirmShutdown()) { - break; + } finally { + // Always handle shutdown even if the loop processing threw an exception. + try { + if (isShuttingDown()) { + closeAll(); + if (confirmShutdown()) { + break; + } } + } catch (Error e) { + throw (Error) e; + } catch (Throwable t) { + handleLoopException(t); } - } catch (Throwable t) { - handleLoopException(t); } } } diff --git a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java index 3182ca9890..5acdff64d5 100644 --- a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java @@ -515,19 +515,24 @@ public final class NioEventLoop extends SingleThreadEventLoop { logger.debug(CancelledKeyException.class.getSimpleName() + " raised by a Selector {} - JDK bug?", selector, e); } + } catch (Error e) { + throw (Error) e; } catch (Throwable t) { handleLoopException(t); - } - // Always handle shutdown even if the loop processing threw an exception. - try { - if (isShuttingDown()) { - closeAll(); - if (confirmShutdown()) { - return; + } finally { + // Always handle shutdown even if the loop processing threw an exception. + try { + if (isShuttingDown()) { + closeAll(); + if (confirmShutdown()) { + return; + } } + } catch (Error e) { + throw (Error) e; + } catch (Throwable t) { + handleLoopException(t); } - } catch (Throwable t) { - handleLoopException(t); } } }