Skip to content

Commit

Permalink
Stop HashedWheelTimer after exception in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dvbobrov committed Mar 16, 2016
1 parent 53884ef commit d9c97a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Expand Up @@ -96,11 +96,7 @@ public ClusterConnectionManager(ClusterServersConfig cfg, Config config) {
}

if (lastPartitions.isEmpty()) {
try {
group.shutdownGracefully().await();
} catch (Exception e) {
// skip it
}
stopThreads();
throw new RedisConnectionException("Can't connect to servers!", lastException);
}

Expand Down
Expand Up @@ -202,11 +202,7 @@ protected void init(MasterSlaveServersConfig config) {
try {
initEntry(config);
} catch (RuntimeException e) {
try {
group.shutdownGracefully().await();
} catch (Exception e1) {
// skip
}
stopThreads();
throw e;
}
}
Expand Down Expand Up @@ -741,4 +737,12 @@ public ConnectionEventsHub getConnectionEventsHub() {
return connectionEventsHub;
}

protected void stopThreads() {
timer.stop();
try {
group.shutdownGracefully().await();
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
}
}

0 comments on commit d9c97a8

Please sign in to comment.