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