Elffuss BraidHub

kikocis/java-driver public

Avoid Session leak using connect() with wrong keyspace name (JAVA-806)
Changesete4567c749def7472df28cf5ad7d09c3e4ca2bdbe8d6348e3c709c3c01b365ab7
AuthorFlavio <f.baro@libero.it> · 2015-06-11 12:11 +02:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2015-06-11 16:17 +02:00
Parentse101ab366c7b

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +10 −8
@@ -280,14 +280,16 @@
280280 long timeout = getConfiguration().getSocketOptions().getConnectTimeoutMillis();
281281 Session session = connect();
282282 try {
283- ResultSetFuture future = session.executeAsync("USE " + keyspace);
284- // Note: using the connection timeout isn't perfectly correct, we should probably change that someday
285- Uninterruptibles.getUninterruptibly(future, timeout, TimeUnit.MILLISECONDS);
286- return session;
287- } catch (TimeoutException e) {
288- throw new DriverInternalError(String.format("No responses after %d milliseconds while setting current keyspace. This should not happen, unless you have setup a very low connection timeout.", timeout));
289- } catch (ExecutionException e) {
290- throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
283+ try {
284+ ResultSetFuture future = session.executeAsync("USE " + keyspace);
285+ // Note: using the connection timeout isn't perfectly correct, we should probably change that someday
286+ Uninterruptibles.getUninterruptibly(future, timeout, TimeUnit.MILLISECONDS);
287+ return session;
288+ } catch (TimeoutException e) {
289+ throw new DriverInternalError(String.format("No responses after %d milliseconds while setting current keyspace. This should not happen, unless you have setup a very low connection timeout.", timeout));
290+ } catch (ExecutionException e) {
291+ throw DefaultResultSetFuture.extractCauseFromExecutionException(e);
292+ }
291293 } catch (RuntimeException e) {
292294 session.close();
293295 throw e;