Elffuss BraidHub

kikocis/java-driver public

Keep a reference to PreparedStatement so it doesn't get GC'd from cache.

Cluster.Manager.preparedQueries is a weak value map so as
PreparedStatement instances become dereferenced from client code the
garbage collector may collect these instances and thus remove elements
from the map.
Changeset3b0bb96beb2896d0e19f7a06dec300a4414f8ebe4bae2904a8421b1ae595e46b
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-10-27 14:38 -05:00
Committerolim7t <omichallat+github@gmail.com> · 2015-11-05 18:37 +01:00
Parents11d8732e0b5b

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/QueryOptionsTest.java +2 −1
@@ -66,7 +66,8 @@
6666 public void validatePrepared(boolean expectAll) {
6767 // Prepare the statement
6868 String query = "select sansa_stark from the_known_world";
69- session.prepare(query);
69+ PreparedStatement statement = session.prepare(query);
70+ assertThat(cluster.manager.preparedQueries).containsValue(statement);
7071
7172 // Ensure prepared properly based on expectation.
7273 List<PreparedStatementPreparation> preparationOne = scassandra.retrievePreparedStatementPreparations(1);