Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ void followLeader() throws InterruptedException {
}
} catch (Exception e) {
LOG.warn("Exception when following the leader", e);
try {
sock.close();
} catch (IOException e1) {
e1.printStackTrace();
}
closeSocket();

// clear pending revalidations
pendingRevalidations.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ public void shutdown() {
self.setZooKeeperServer(null);
self.closeAllConnections();
self.adminServer.setZooKeeperServer(null);
closeSocket();
// shutdown previous zookeeper
if (zk != null) {
zk.shutdown();
Expand All @@ -682,4 +683,14 @@ public void shutdown() {
boolean isRunning() {
return self.isRunning() && zk.isRunning();
}

void closeSocket() {
try {
if (sock != null && !sock.isClosed()) {
sock.close();
}
} catch (IOException e) {
LOG.warn("Ignoring error closing connection to leader", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ void observeLeader() throws Exception {
}
} catch (Exception e) {
LOG.warn("Exception when observing the leader", e);
try {
sock.close();
} catch (IOException e1) {
e1.printStackTrace();
}
closeSocket();

// clear pending revalidations
pendingRevalidations.clear();
Expand Down