文章首发地址
大家应该早就听说过臭名昭著的Java NIO epoll的Bug,它会导致Selector空轮询,最终导致CPU使用率达到100%。官方声称JDK 1.6的update18修复了该问题,但是直到JDK 1.7该问题仍旧存在,只不过该Bug发生概率降低了一些而已,并没有被根本解决。出现此Bug是因为当Selector轮询结果为空时,没有进行wakeup或对新消息及时进行处理,导致发生了空轮询,CPU使用率达到了100%。我们来看一下这个问题在issue中的原始描述。
This is an issue with poll (and epoll) on Linux.If a file descriptor for a connected socket ispolled with a request event mask of 0,and if the connection is abruptly terminated (RST)then the poll wakes up with the POLLHUP (and maybe POLLERR) bit set in the returnedevent set.The implication of this behaviour is that Selector will wakeup and as the interestset