Allow EventLoops to rethrow Error (#10694)
Motivation: Thread.stop() works by producing a ThreadDeath error in the target thread. EventLoops swallow all Throwables, which makes them effectively unkillable. This is effectively a memory leak, for our application. Beside this we should also just regrow all `Error` as there is almost no way to recover. Modification: Edit the EventLoops that swallow Throwables to instead rethrow Error. Result: `EventLoop` can crash if `Error` is thrown
This commit is contained in:
parent
d58d1add34
commit
090e9a7271
@ -390,9 +390,11 @@ 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);
|
||||
}
|
||||
} finally {
|
||||
// Always handle shutdown even if the loop processing threw an exception.
|
||||
try {
|
||||
if (isShuttingDown()) {
|
||||
@ -401,11 +403,14 @@ class EpollEventLoop extends SingleThreadEventLoop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
throw (Error) e;
|
||||
} catch (Throwable t) {
|
||||
handleLoopException(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visible only for testing!
|
||||
|
@ -297,9 +297,11 @@ 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);
|
||||
}
|
||||
} finally {
|
||||
// Always handle shutdown even if the loop processing threw an exception.
|
||||
try {
|
||||
if (isShuttingDown()) {
|
||||
@ -308,11 +310,14 @@ final class KQueueEventLoop extends SingleThreadEventLoop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
throw (Error) e;
|
||||
} catch (Throwable t) {
|
||||
handleLoopException(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Queue<Runnable> newTaskQueue(int maxPendingTasks) {
|
||||
|
@ -515,9 +515,11 @@ 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);
|
||||
}
|
||||
} finally {
|
||||
// Always handle shutdown even if the loop processing threw an exception.
|
||||
try {
|
||||
if (isShuttingDown()) {
|
||||
@ -526,11 +528,14 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
throw (Error) e;
|
||||
} catch (Throwable t) {
|
||||
handleLoopException(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if selectCnt should be reset
|
||||
private boolean unexpectedSelectorWakeup(int selectCnt) {
|
||||
|
Loading…
Reference in New Issue
Block a user