kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | b71ec2203d70994ea4d39138ee41e63be226e75caca49c09588f5444ffca0290 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-02-06 14:41 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-02-11 12:34 +01:00 |
| Parents | 2f29ae9aea6b |
1 file changed
modified driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java +8 −3
| @@ -293,10 +293,8 @@ | ||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | Host queriedHost = current; |
| 296 | + boolean releaseConnection = true; | |
| 296 | 297 | try { |
| 297 | - if (connection instanceof PooledConnection) | |
| 298 | - ((PooledConnection)connection).release(); | |
| 299 | - | |
| 300 | 298 | switch (response.type) { |
| 301 | 299 | case RESULT: |
| 302 | 300 | setFinalResult(connection, response); |
| @@ -420,6 +418,7 @@ | ||
| 420 | 418 | } |
| 421 | 419 | |
| 422 | 420 | try { |
| 421 | + releaseConnection = false; // we're reusing it for the prepare call | |
| 423 | 422 | write(connection, prepareAndRetry(toPrepare.getQueryString())); |
| 424 | 423 | } finally { |
| 425 | 424 | // Always reset the previous keyspace if needed |
| @@ -467,6 +466,9 @@ | ||
| 467 | 466 | } catch (Exception e) { |
| 468 | 467 | setFinalException(connection, e); |
| 469 | 468 | } finally { |
| 469 | + if (releaseConnection && connection instanceof PooledConnection) | |
| 470 | + ((PooledConnection)connection).release(); | |
| 471 | + | |
| 470 | 472 | if (queriedHost != null) |
| 471 | 473 | manager.cluster.manager.reportLatency(queriedHost, latency); |
| 472 | 474 | } |
| @@ -495,6 +497,9 @@ | ||
| 495 | 497 | return; |
| 496 | 498 | } |
| 497 | 499 | |
| 500 | + if (connection instanceof PooledConnection) | |
| 501 | + ((PooledConnection)connection).release(); | |
| 502 | + | |
| 498 | 503 | // TODO should we check the response ? |
| 499 | 504 | switch (response.type) { |
| 500 | 505 | case RESULT: |