kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | b8caef2fdfabf599a7721c78d121037b93aed2690e56060a33fe86a8ba59c6d9 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-05-21 10:31 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-05-21 10:31 +02:00 |
| Parents | e885ef712d80, 23fe4ec1a4f9 |
4 files changed
modified driver-core/CHANGELOG.rst +13 −0
| @@ -4,8 +4,21 @@ | ||
| 4 | 4 | 2.0.11: |
| 5 | 5 | ------- |
| 6 | 6 | |
| 7 | +Merged from 2.0.10_fixes branch: | |
| 8 | + | |
| 7 | 9 | - [improvement] Use Netty's pooled ByteBufAllocator by default (JAVA-756) |
| 8 | 10 | - [improvement] Expose "unsafe" paging state API (JAVA-759) |
| 11 | +- [bug] Fix getObject by name (JAVA-767) | |
| 12 | +- [bug] Prevent race during pool initialization (JAVA-768) | |
| 13 | + | |
| 14 | + | |
| 15 | +2.0.10.1: | |
| 16 | +--------- | |
| 17 | + | |
| 18 | +- [improvement] Use Netty's pooled ByteBufAllocator by default (JAVA-756) | |
| 19 | +- [improvement] Expose "unsafe" paging state API (JAVA-759) | |
| 20 | +- [bug] Fix getObject by name (JAVA-767) | |
| 21 | +- [bug] Prevent race during pool initialization (JAVA-768) | |
| 9 | 22 | |
| 10 | 23 | |
| 11 | 24 | 2.0.10: |
modified driver-core/src/main/java/com/datastax/driver/core/AbstractGettableData.java +1 −1
| @@ -310,6 +310,6 @@ | ||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | public Object getObject(String name) { |
| 313 | - return getValue(metadata.getFirstIdx(name)); | |
| 313 | + return getObject(metadata.getFirstIdx(name)); | |
| 314 | 314 | } |
| 315 | 315 | } |
modified driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java +7 −9
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | private final AtomicReference<CloseFuture> closeFuture = new AtomicReference<CloseFuture>(); |
| 73 | 73 | |
| 74 | 74 | private enum Phase { INITIALIZING, READY, INIT_FAILED, CLOSING } |
| 75 | - private volatile Phase phase = Phase.INITIALIZING; | |
| 75 | + private final AtomicReference<Phase> phase = new AtomicReference<Phase>(Phase.INITIALIZING); | |
| 76 | 76 | |
| 77 | 77 | public HostConnectionPool(final Host host, HostDistance hostDistance, final SessionManager manager){ |
| 78 | 78 | assert hostDistance != HostDistance.IGNORED; |
| @@ -134,14 +134,14 @@ | ||
| 134 | 134 | forceClose(connections); |
| 135 | 135 | } else { |
| 136 | 136 | logger.trace("Created connection pool to host {}", host); |
| 137 | - phase = Phase.READY; | |
| 137 | + phase.compareAndSet(Phase.INITIALIZING, Phase.READY); | |
| 138 | 138 | initFuture.set(null); |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | @Override |
| 143 | 143 | public void onFailure(Throwable t) { |
| 144 | - phase = Phase.INIT_FAILED; | |
| 144 | + phase.compareAndSet(Phase.INITIALIZING, Phase.INIT_FAILED); | |
| 145 | 145 | forceClose(connections); |
| 146 | 146 | initFuture.setException(t); |
| 147 | 147 | } |
| @@ -161,9 +161,7 @@ | ||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public Connection borrowConnection(long timeout, TimeUnit unit) throws ConnectionException, TimeoutException { |
| 164 | - if (phase == Phase.INITIALIZING) | |
| 165 | - throw new ConnectionException(host.getSocketAddress(), "Pool is initializing."); | |
| 166 | - | |
| 164 | + Phase phase = this.phase.get(); | |
| 167 | 165 | if (phase != Phase.READY) |
| 168 | 166 | // Note: throwing a ConnectionException is probably fine in practice as it will trigger the creation of a new host. |
| 169 | 167 | // That being said, maybe having a specific exception could be cleaner. |
| @@ -393,7 +391,7 @@ | ||
| 393 | 391 | break; |
| 394 | 392 | } |
| 395 | 393 | |
| 396 | - if (phase != Phase.READY) { | |
| 394 | + if (phase.get() != Phase.READY) { | |
| 397 | 395 | open.decrementAndGet(); |
| 398 | 396 | return false; |
| 399 | 397 | } |
| @@ -410,7 +408,7 @@ | ||
| 410 | 408 | newConnection.state.compareAndSet(RESURRECTING, OPEN); // no-op if it was already OPEN |
| 411 | 409 | |
| 412 | 410 | // We might have raced with pool shutdown since the last check; ensure the connection gets closed in case the pool did not do it. |
| 413 | - if (phase != Phase.READY && !newConnection.isClosed()) { | |
| 411 | + if (isClosed() && !newConnection.isClosed()) { | |
| 414 | 412 | close(newConnection); |
| 415 | 413 | open.decrementAndGet(); |
| 416 | 414 | return false; |
| @@ -555,7 +553,7 @@ | ||
| 555 | 553 | if (future != null) |
| 556 | 554 | return future; |
| 557 | 555 | |
| 558 | - phase = Phase.CLOSING; | |
| 556 | + phase.set(Phase.CLOSING); | |
| 559 | 557 | |
| 560 | 558 | // Wake up all threads that wait |
| 561 | 559 | signalAllAvailableConnection(); |
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeIntegrationTest.java +1 −0
| @@ -118,6 +118,7 @@ | ||
| 118 | 118 | |
| 119 | 119 | // Ensure that bs.getObject() also returns the expected value. |
| 120 | 120 | assertThat(bs.getObject(0)).isEqualTo(table.sampleValue); |
| 121 | + assertThat(bs.getObject("v")).isEqualTo(table.sampleValue); | |
| 121 | 122 | } |
| 122 | 123 | |
| 123 | 124 | /** |