Issue #2755 - ManagedSelector 100% CPU spin.

Added check for thread interrupted.
If interrupted and ManagedSelector is not running, bail out.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2018-08-01 16:57:08 +02:00
parent 0ba1d9b5a5
commit a090741a60
1 changed files with 4 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
@ -426,6 +427,9 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
if (LOG.isDebugEnabled())
LOG.debug("Selector {} woken up from select, {}/{}/{} selected", selector, selected, selector.selectedKeys().size(), selector.keys().size());
if (Thread.interrupted() && !isRunning())
throw new ClosedSelectorException();
int updates;
synchronized(ManagedSelector.this)
{