|
15 | 15 | */ |
16 | 16 | package com.datastax.driver.core; |
17 | 17 |
|
18 | | -import java.net.InetAddress; |
19 | 18 | import java.net.InetSocketAddress; |
20 | 19 | import java.nio.ByteBuffer; |
21 | 20 | import java.util.*; |
|
30 | 29 | import org.slf4j.LoggerFactory; |
31 | 30 |
|
32 | 31 |
|
33 | | -import com.datastax.driver.core.exceptions.AuthenticationException; |
34 | 32 | import com.datastax.driver.core.exceptions.DriverInternalError; |
35 | 33 | import com.datastax.driver.core.exceptions.UnsupportedFeatureException; |
36 | 34 | import com.datastax.driver.core.policies.LoadBalancingPolicy; |
@@ -270,7 +268,11 @@ private boolean replacePool(Host host, HostDistance distance, HostConnectionPool |
270 | 268 | return false; |
271 | 269 |
|
272 | 270 | HostConnectionPool newPool = new HostConnectionPool(host, distance, this); |
273 | | - pools.put(host, newPool); |
| 271 | + previous = pools.put(host, newPool); |
| 272 | + if (previous != null && !previous.isClosed()) { |
| 273 | + logger.warn("Replacing a pool that wasn't closed. Closing it now, but this was not expected."); |
| 274 | + previous.closeAsync(); |
| 275 | + } |
274 | 276 |
|
275 | 277 | // If we raced with a session shutdown, ensure that the pool will be closed. |
276 | 278 | if (isClosing) |
@@ -348,7 +350,7 @@ void updateCreatedPools(ListeningExecutorService executor) { |
348 | 350 | HostConnectionPool pool = pools.get(h); |
349 | 351 |
|
350 | 352 | if (pool == null) { |
351 | | - if (dist != HostDistance.IGNORED && h.isUp()) |
| 353 | + if (dist != HostDistance.IGNORED && h.state == Host.State.UP) |
352 | 354 | poolCreationFutures.add(maybeAddPool(h, executor)); |
353 | 355 | } else if (dist != pool.hostDistance) { |
354 | 356 | if (dist == HostDistance.IGNORED) { |
@@ -381,7 +383,7 @@ void updateCreatedPools(Host h, ListeningExecutorService executor) { |
381 | 383 |
|
382 | 384 | try { |
383 | 385 | if (pool == null) { |
384 | | - if (dist != HostDistance.IGNORED && h.isUp()) |
| 386 | + if (dist != HostDistance.IGNORED && h.state == Host.State.UP) |
385 | 387 | maybeAddPool(h, executor).get(); |
386 | 388 | } else if (dist != pool.hostDistance) { |
387 | 389 | if (dist == HostDistance.IGNORED) { |
|
0 commit comments