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,19 +390,24 @@ class EpollEventLoop extends SingleThreadEventLoop {
|
|||||||
//increase the size of the array as we needed the whole space for the events
|
//increase the size of the array as we needed the whole space for the events
|
||||||
events.increase();
|
events.increase();
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
throw (Error) e;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleLoopException(t);
|
handleLoopException(t);
|
||||||
}
|
} finally {
|
||||||
// Always handle shutdown even if the loop processing threw an exception.
|
// Always handle shutdown even if the loop processing threw an exception.
|
||||||
try {
|
try {
|
||||||
if (isShuttingDown()) {
|
if (isShuttingDown()) {
|
||||||
closeAll();
|
closeAll();
|
||||||
if (confirmShutdown()) {
|
if (confirmShutdown()) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
throw (Error) e;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
handleLoopException(t);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
handleLoopException(t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,19 +297,24 @@ final class KQueueEventLoop extends SingleThreadEventLoop {
|
|||||||
//increase the size of the array as we needed the whole space for the events
|
//increase the size of the array as we needed the whole space for the events
|
||||||
eventList.realloc(false);
|
eventList.realloc(false);
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
throw (Error) e;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleLoopException(t);
|
handleLoopException(t);
|
||||||
}
|
} finally {
|
||||||
// Always handle shutdown even if the loop processing threw an exception.
|
// Always handle shutdown even if the loop processing threw an exception.
|
||||||
try {
|
try {
|
||||||
if (isShuttingDown()) {
|
if (isShuttingDown()) {
|
||||||
closeAll();
|
closeAll();
|
||||||
if (confirmShutdown()) {
|
if (confirmShutdown()) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
throw (Error) e;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
handleLoopException(t);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
handleLoopException(t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,19 +515,24 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
logger.debug(CancelledKeyException.class.getSimpleName() + " raised by a Selector {} - JDK bug?",
|
logger.debug(CancelledKeyException.class.getSimpleName() + " raised by a Selector {} - JDK bug?",
|
||||||
selector, e);
|
selector, e);
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
throw (Error) e;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleLoopException(t);
|
handleLoopException(t);
|
||||||
}
|
} finally {
|
||||||
// Always handle shutdown even if the loop processing threw an exception.
|
// Always handle shutdown even if the loop processing threw an exception.
|
||||||
try {
|
try {
|
||||||
if (isShuttingDown()) {
|
if (isShuttingDown()) {
|
||||||
closeAll();
|
closeAll();
|
||||||
if (confirmShutdown()) {
|
if (confirmShutdown()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Error e) {
|
||||||
|
throw (Error) e;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
handleLoopException(t);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
handleLoopException(t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user