Elffuss BraidHub

kikocis/java-driver public

Ensure pool is properly closed in onDown (JAVA-417).
Changesetc650795a337f621cf0a5e2ca620ccc5192ed01dfe4678c7e24462bb67dc651ec
Authorolim7t <omichallat+github@gmail.com> · 2014-08-08 10:29 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-08-08 15:01 +02:00
Parents850ce3bd6c2b

Browse the files at this changeset

4 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -7,6 +7,7 @@
77 - [bug] Release connections on ResultSetFuture#cancel (JAVA-407)
88 - [bug] Fix handling of SimpleStatement with values in query builder
99 batches (JAVA-393)
10+- [bug] Ensure pool is properly closed in onDown (JAVA-417)
1011
1112
1213 2.0.4:
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +4 −2
@@ -628,9 +628,11 @@
628628 public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) {
629629 // If we've closed the channel client side then we don't really want to defunct the connection, but
630630 // if there is remaining thread waiting on us, we still want to wake them up
631- if (!isInitialized || isClosed())
631+ if (!isInitialized || isClosed()) {
632632 errorOutAllHandler(new TransportException(address, "Channel has been closed"));
633- else
633+ // we still want to force so that the future completes
634+ Connection.this.closeAsync().force();
635+ } else
634636 defunct(new TransportException(address, "Channel has been closed"));
635637 }
636638 }
modified driver-core/src/main/java/com/datastax/driver/core/PooledConnection.java +1 −1
@@ -45,7 +45,7 @@
4545 return;
4646
4747 if (hostIsDown) {
48- pool.closeAsync();
48+ pool.closeAsync().force();
4949 } else {
5050 pool.replace(this);
5151 }
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +3 −3
@@ -283,10 +283,10 @@
283283 });
284284 }
285285
286- ListenableFuture<?> removePool(Host host) {
286+ CloseFuture removePool(Host host) {
287287 final HostConnectionPool pool = pools.remove(host);
288288 return pool == null
289- ? Futures.immediateFuture(null)
289+ ? CloseFuture.immediateFuture()
290290 : pool.closeAsync();
291291 }
292292
@@ -341,7 +341,7 @@
341341 void onDown(Host host) throws InterruptedException, ExecutionException {
342342 // Note that with well behaved balancing policy (that ignore dead nodes), the removePool call is not necessary
343343 // since updateCreatedPools should take care of it. But better protect against non well behaving policies.
344- removePool(host).get();
344+ removePool(host).force().get();
345345 updateCreatedPools(MoreExecutors.sameThreadExecutor());
346346 }
347347