Elffuss BraidHub

kikocis/java-driver public

Ensure defunct connections are completely closed (JAVA-394).
Changeset2cf768d3be548ed04545a03db470c9dbc799a61f272df15638622d171506d2d9
Authorolim7t <omichallat+github@gmail.com> · 2014-07-16 21:29 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-07-16 21:29 +02:00
Parentsfc9d0b03cdae

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +4 −4
@@ -234,7 +234,6 @@
234234 logger.debug("Defuncting connection to " + address, e);
235235 isDefunct = true;
236236
237- // If we're initializing the connection, we know there is not handlers yet
238237 ConnectionException ce = e instanceof ConnectionException
239238 ? (ConnectionException)e
240239 : new ConnectionException(address, "Connection problem", e);
@@ -247,10 +246,11 @@
247246 notifyOwnerWhenDefunct(isDown);
248247 }
249248
250- if (!isInitialized)
251- dispatcher.errorOutAllHandler(ce);
249+ // Force the connection to close to make sure the future completes. Otherwise force() might never get called and
250+ // threads will wait on the future forever.
251+ // (this also errors out pending handlers)
252+ closeAsync().force();
252253
253- closeAsync();
254254 return e;
255255 }
256256