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:
greenjustin 2020-10-24 08:56:33 -04:00 committed by Norman Maurer
parent 930aec7f0a
commit 5ad80c5887
3 changed files with 7 additions and 1 deletions

View File

@ -298,7 +298,7 @@ public class EpollHandler implements IoHandler {
int strategy = selectStrategy.calculateStrategy(selectNowSupplier, !context.canBlock());
switch (strategy) {
case SelectStrategy.CONTINUE:
return 0 ;
return 0;
case SelectStrategy.BUSY_WAIT:
strategy = epollBusyWait();
@ -345,6 +345,8 @@ public class EpollHandler implements IoHandler {
//increase the size of the array as we needed the whole space for the events
events.increase();
}
} catch (Error error) {
throw error;
} catch (Throwable t) {
handleLoopException(t);
}

View File

@ -306,6 +306,8 @@ public final class KQueueHandler implements IoHandler {
//increase the size of the array as we needed the whole space for the events
eventList.realloc(false);
}
} catch (Error e) {
throw e;
} catch (Throwable t) {
handleLoopException(t);
}

View File

@ -451,6 +451,8 @@ public final class NioHandler implements IoHandler {
cancelledKeys = 0;
needsToSelectAgain = false;
handled = processSelectedKeys();
} catch (Error e) {
throw e;
} catch (Throwable t) {
handleLoopException(t);
}