prevent RejectedExecutionExceptions on shutdown

pull/24/head
Zlatin Balevsky 2019-10-25 06:13:20 +01:00
parent fcd3414e02
commit 43987be463
1 changed files with 7 additions and 5 deletions

View File

@ -62,7 +62,7 @@ class ConnectionEstablisher {
void stop() {
timer.cancel()
executor.shutdownNow()
closer.shutdown()
closer.shutdownNow()
}
private void connectIfNeeded() {
@ -123,10 +123,12 @@ class ConnectionEstablisher {
}
private void fail(Endpoint endpoint) {
closer.execute {
endpoint.close()
eventBus.publish(new ConnectionEvent(endpoint: endpoint, incoming: false, leaf: false, status: ConnectionAttemptStatus.FAILED))
} as Runnable
if (!closer.isShutdown()) {
closer.execute {
endpoint.close()
eventBus.publish(new ConnectionEvent(endpoint: endpoint, incoming: false, leaf: false, status: ConnectionAttemptStatus.FAILED))
} as Runnable
}
}
private void readK(Endpoint e) {