From d8d800d614f74ead919c5f45569c2d4ad69d2ad6 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Mon, 2 Feb 2015 09:11:17 +0000 Subject: [PATCH] moved shutdownNow only to the main thread Conflicts: src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java --- .../map/AbstractChannelReplicator.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java b/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java index 3336cac90..1bd339a4c 100644 --- a/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java @@ -56,7 +56,6 @@ abstract class AbstractChannelReplicator implements Closeable { static final int SIZE_OF_SIZE = 4; public static final int SIZE_OF_TRANSACTION_ID = 8; - public static final int SIZE_OF_TIME_SHIFT = 2; private static final Logger LOG = LoggerFactory.getLogger(AbstractChannelReplicator.class); @@ -228,7 +227,15 @@ abstract class AbstractChannelReplicator implements Closeable { if (Thread.interrupted()) LOG.warn("Already interrupted"); long start = System.currentTimeMillis(); - closeResources(); + try { + closeResources(); + if (!executorService.awaitTermination(5, TimeUnit.MILLISECONDS)) { + executorService.shutdownNow(); + executorService.awaitTermination(10, TimeUnit.SECONDS); + } + } catch (InterruptedException e) { + LOG.error("", e); + } try { if (future != null) @@ -254,21 +261,9 @@ abstract class AbstractChannelReplicator implements Closeable { } } - public void closeResources() { + public void closeResources() throws InterruptedException { isClosed = true; executorService.shutdown(); - - try { - executorService.awaitTermination(5, TimeUnit.MILLISECONDS); - } catch (Exception e) { - executorService.shutdownNow(); - try { - executorService.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e1) { - LOG.error("", e); - } - } - closeables.closeQuietly(); }