kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 2cf768d3be548ed04545a03db470c9dbc799a61f272df15638622d171506d2d9 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-07-16 21:29 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-07-16 21:29 +02:00 |
| Parents | fc9d0b03cdae |
1 file changed
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +4 −4
| @@ -234,7 +234,6 @@ | ||
| 234 | 234 | logger.debug("Defuncting connection to " + address, e); |
| 235 | 235 | isDefunct = true; |
| 236 | 236 | |
| 237 | - // If we're initializing the connection, we know there is not handlers yet | |
| 238 | 237 | ConnectionException ce = e instanceof ConnectionException |
| 239 | 238 | ? (ConnectionException)e |
| 240 | 239 | : new ConnectionException(address, "Connection problem", e); |
| @@ -247,10 +246,11 @@ | ||
| 247 | 246 | notifyOwnerWhenDefunct(isDown); |
| 248 | 247 | } |
| 249 | 248 | |
| 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(); | |
| 252 | 253 | |
| 253 | - closeAsync(); | |
| 254 | 254 | return e; |
| 255 | 255 | } |
| 256 | 256 |