kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a1b64c4681a0a0eb8f6a604b665ba8308c8d504a379cc44ebd46bb776d4c434d |
|---|---|
| Author | tommy stendahl <tommy.stendahl@ericsson.com> · 2015-08-14 08:33 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-10-30 16:48 +01:00 |
| Parents | 0a81df133747 |
3 files changed
modified changelog/README.md +1 −0
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | - [improvement] JAVA-921: Add SimpleStatement.getValuesCount(). |
| 10 | 10 | - [bug] JAVA-901: Move call to connection.release() out of cancelHandler. |
| 11 | 11 | - [bug] JAVA-960: Avoid race in control connection shutdown. |
| 12 | +- [bug] JAVA-656: Fix NPE in ControlConnection.updateLocationInfo. | |
| 12 | 13 | |
| 13 | 14 | |
| 14 | 15 | ### 2.0.11 |
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +9 −2
| @@ -587,8 +587,15 @@ | ||
| 587 | 587 | if (host == null) { |
| 588 | 588 | // We don't know that node, create the Host object but wait until we've set the known |
| 589 | 589 | // info before signaling the addition. |
| 590 | - host = cluster.metadata.add(foundHosts.get(i)); | |
| 591 | - isNew = true; | |
| 590 | + Host newHost = cluster.metadata.newHost(foundHosts.get(i)); | |
| 591 | + Host existing = cluster.metadata.addIfAbsent(newHost); | |
| 592 | + if (existing == null) { | |
| 593 | + host = newHost; | |
| 594 | + isNew = true; | |
| 595 | + } else { | |
| 596 | + host = existing; | |
| 597 | + isNew = false; | |
| 598 | + } | |
| 592 | 599 | } |
| 593 | 600 | if (dcs.get(i) != null || racks.get(i) != null) |
| 594 | 601 | updateLocationInfo(host, dcs.get(i), racks.get(i), isInitialConnection, cluster); |
modified driver-core/src/main/java/com/datastax/driver/core/Metadata.java +10 −3
| @@ -282,10 +282,17 @@ | ||
| 282 | 282 | this.tokenMap = TokenMap.build(factory, allTokens, keyspaces.values()); |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | + Host newHost(InetSocketAddress address) { | |
| 286 | + return new Host(address, cluster.convictionPolicyFactory, cluster); | |
| 287 | + } | |
| 288 | + | |
| 289 | + Host addIfAbsent(Host host) { | |
| 290 | + Host previous = hosts.putIfAbsent(host.getSocketAddress(), host); | |
| 291 | + return previous == null ? host : null; | |
| 292 | + } | |
| 293 | + | |
| 285 | 294 | Host add(InetSocketAddress address) { |
| 286 | - Host newHost = new Host(address, cluster.convictionPolicyFactory, cluster); | |
| 287 | - Host previous = hosts.putIfAbsent(address, newHost); | |
| 288 | - return previous == null ? newHost : null; | |
| 295 | + return addIfAbsent(newHost(address)); | |
| 289 | 296 | } |
| 290 | 297 | |
| 291 | 298 | boolean remove(Host host) { |