Elffuss BraidHub

kikocis/java-driver public

Fix changelog
Changeset639e297e18468656e84b29661b49d7c43838c0efa64d861b34d1016be3b71144
AuthorSylvain Lebresne <sylvain@datastax.com> · 2014-01-16 15:51 +01:00
CommitterSylvain Lebresne <sylvain@datastax.com> · 2014-01-16 15:51 +01:00
Parents839d1c3411b4

Browse the files at this changeset

2 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -5,6 +5,7 @@
55 ------
66
77 - [improvement] Make most main objects interface to facilitate testing/mocking (JAVA-195)
8+- [improvement] Avoid preparing a statement multiple time per host with multiple sessions
89 - [bug] Fix potential thread leaks when shutting down Metrics (JAVA-232)
910 - [bug] Fix potential NPE in HostConnectionPool (JAVA-231)
1011
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +3 −1
@@ -146,6 +146,8 @@
146146 PreparedStatement stmt = PreparedStatement.fromMessage(pmsg, cluster.getMetadata(), query, poolsState.keyspace);
147147 cluster.manager.addPrepared(stmt);
148148 try {
149+ // All Sessions are connected to the same nodes so it's enough to prepare only the nodes of this session.
150+ // If that changes, we'll have to make sure this propagate to other sessions too.
149151 prepare(stmt.getQueryString(), future.getAddress());
150152 } catch (InterruptedException e) {
151153 Thread.currentThread().interrupt();
@@ -298,7 +300,7 @@
298300 new RequestHandler(this, callback, query).sendRequest();
299301 }
300302
301- void prepare(String query, InetAddress toExclude) throws InterruptedException {
303+ private void prepare(String query, InetAddress toExclude) throws InterruptedException {
302304 for (Map.Entry<Host, HostConnectionPool> entry : pools.entrySet()) {
303305 if (entry.getKey().getAddress().equals(toExclude))
304306 continue;