kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 0df8e9f3e4b8f1f5fa98a0fe180829474ecb1b4a9a205ce4e2056c8227bd6b9f |
|---|---|
| Author | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-25 15:06 +01:00 |
| Committer | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-25 15:06 +01:00 |
| Parents | 80afbe6294e6 |
2 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | - [bug] Make sure connections are returned to the right pools (JAVA-255) |
| 14 | 14 | - [bug] Use date string in query build to work-around CASSANDRA-6718 (JAVA-264) |
| 15 | 15 | - [bug] Always return the PreparedStatement object that is cache internally (JAVA-263) |
| 16 | +- [bug] Fix race when multiple connect are done in parallel (JAVA-261) | |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | 1.0.5: |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +7 −3
| @@ -735,7 +735,7 @@ | ||
| 735 | 735 | */ |
| 736 | 736 | class Manager implements Host.StateListener, Connection.DefaultResponseHandler { |
| 737 | 737 | |
| 738 | - private final AtomicBoolean isInit = new AtomicBoolean(false); | |
| 738 | + private boolean isInit; | |
| 739 | 739 | |
| 740 | 740 | // Initial contacts point |
| 741 | 741 | final List<InetAddress> contactPoints; |
| @@ -789,8 +789,10 @@ | ||
| 789 | 789 | this.configuration.register(this); |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - private void init() { | |
| 793 | - if (!isInit.compareAndSet(false, true)) | |
| 792 | + // Initialization is not too performance intensive and in practice there shouldn't be contention | |
| 793 | + // on it so synchronized is good enough. | |
| 794 | + private synchronized void init() { | |
| 795 | + if (isInit) | |
| 794 | 796 | return; |
| 795 | 797 | |
| 796 | 798 | // Note: we mark the initial contact point as UP, because we have no prior |
| @@ -815,6 +817,8 @@ | ||
| 815 | 817 | } |
| 816 | 818 | throw e; |
| 817 | 819 | } |
| 820 | + | |
| 821 | + isInit = true; | |
| 818 | 822 | } |
| 819 | 823 | |
| 820 | 824 | Cluster getCluster() { |