processSelectedKey should be an hot path and very likely to be compiled at C2 level so I don't think it would make any difference perf-wise. For readability is fine, agree :) @MrYangxf sounds good... Can you please submit a PR ? @normanmaurer Of course :)
this `return` can be removed now.  this seems to violate the original logic. The healthy channel  may be closed when `eventLoop != this` @MrYangxf not sure I understand your concern... With your change `return` is the last statement in the method which makes it redundant.. What I am missing ? @normanmaurer  ...`return` is contained in the `if(!k.isValid())` statement instead of the last line of the method... @MrYangxf doh! stupid me ... I did not notice that there is another scope. You are right, of course. 
A redundant comparison operation
Hi, when I read the source code, I happened to notice this
https://github.com/netty/netty/blob/ff2a7929235257642d8f63edb1c580347307f3ee/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java#L669-L674
The `eventLoop == null` is unnecessary. Although the c2 compiler optimizes it, c1 doesn’t seem to optimize it. Though it’s a small problem，it doesn’t look elegant enough.

equivalent
```java
if (eventLoop == this) {
    unsafe.close(unsafe.voidPromise());
}
return;
```
transport/src/main/java/io/netty/channel/nio/NioEventLoop.java
transport/src/main/java/io/netty/channel/nio/NioEventLoop.java
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 ace430afc95..36a0b76ddc0 100644
--- a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java
+++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java
@@ -666,11 +666,10 @@ private void processSelectedKey(SelectionKey k, AbstractNioChannel ch) {
             // and thus the SelectionKey could be cancelled as part of the deregistration process, but the channel is
             // still healthy and should not be closed.
             // See https://github.com/netty/netty/issues/5125
-            if (eventLoop != this || eventLoop == null) {
-                return;
+            if (eventLoop == this) {
+                // close the channel if the key is not valid anymore
+                unsafe.close(unsafe.voidPromise());
             }
-            // close the channel if the key is not valid anymore
-            unsafe.close(unsafe.voidPromise());
             return;
         }
 
