I've been working with NIO directly for many years and I haven't seen this issue in a very long time. The selector will spin out of control if there are no more file descriptors but that's not the fault of NIO.
What OS is the issue appearing on? What version of Java? Sent from my iPhone > On Jun 10, 2016, at 4:13 AM, Emmanuel Lécharny <elecha...@gmail.com> wrote: > >> Le 10/06/16 à 08:23, Claude Warren a écrit : >> hu_yang3000 mentions 100% CPU usage. > There *is* a 100% CPU usage bug due to some 10 years old bug in the NIO > library. There is no way to get this fixed, even if this has been asked > MANY times to Sun/Oracle. > > This occurs because at some point, during some specific conditions, the > selector is spinning, returning with a 0 value without waiting for the > given timeout. Obviously, having 0 event to deal with, we reenter the > select() immediately, and it loops forever, eating 100% of the CPU. > > The workaround is to doom the selector and register all the keys on this > new selector. That is what the code is doing. > > You can try writing a test for that, but again, there is no > deterministic ways to get the problem trigerred. > > FTR, this issue did not only affect MINA, Netty was also affected (see > https://github.com/netty/netty/issues/327). The solution was suggested > by Jean-François Arcand, who was working on Grizzly > >