From 43987be4632f0a57f70313343d293472c099b326 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 25 Oct 2019 06:13:20 +0100 Subject: [PATCH] prevent RejectedExecutionExceptions on shutdown --- .../core/connection/ConnectionEstablisher.groovy | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionEstablisher.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionEstablisher.groovy index b2553d92..f61cbc3b 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionEstablisher.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionEstablisher.groovy @@ -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) {