UnicastZenPing's PingingRound should prevent opening connections after being closed

This may cause them to leak. Provisioning for it was made in #22277 but sadly a crucial ensureOpen call was forgotten
This commit is contained in:
Boaz Leskes 2016-12-22 18:45:44 +01:00
parent 7d0dbd2082
commit 13c5881f3e
1 changed files with 3 additions and 1 deletions

View File

@ -385,12 +385,14 @@ public class UnicastZenPing extends AbstractComponent implements ZenPing {
try (Releasable ignore = connectionLock.acquire(node.getAddress())) {
result = tempConnections.get(node.getAddress());
if (result == null) {
ensureOpen();
boolean success = false;
result = transportService.openConnection(node, connectionProfile);
try {
transportService.handshake(result, connectionProfile.getHandshakeTimeout().millis());
synchronized (this) {
// acquire lock to prevent concurrent closing
// acquire lock and check if closed, to prevent leaving an open connection after closing
ensureOpen();
Connection existing = tempConnections.put(node.getAddress(), result);
assert existing == null;
success = true;