Elffuss BraidHub

kikocis/java-driver public

Ensure failed control connection attempts always get closed.
Changeset14b391abab4f6009b782b0dda3689df2473c94f29ebab73c395a622a711fa841
Authorolim7t <omichallat+github@gmail.com> · 2014-12-18 13:46 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-12-19 00:22 +01:00
Parents0f17d5b313f1

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +13 −3
@@ -235,7 +235,8 @@
235235 return errors;
236236 }
237237
238- private Connection tryConnect(Host host, boolean isInitialConnection) throws ConnectionException, ExecutionException, InterruptedException, UnsupportedProtocolVersionException, ClusterNameMismatchException {
238+ private Connection tryConnect(Host host, boolean isInitialConnection) throws ConnectionException, ExecutionException, InterruptedException, UnsupportedProtocolVersionException, ClusterNameMismatchException
239+ {
239240 Connection connection = cluster.connectionFactory.open(host);
240241
241242 try {
@@ -258,10 +259,19 @@
258259 refreshSchema(connection, null, null, cluster, isInitialConnection);
259260 return connection;
260261 } catch (BusyConnectionException e) {
261- connection.closeAsync().get();
262+ connection.closeAsync().force();
262263 throw new DriverInternalError("Newly created connection should not be busy");
264+ } catch (InterruptedException e) {
265+ connection.closeAsync().force();
266+ throw e;
267+ } catch (ConnectionException e) {
268+ connection.closeAsync().force();
269+ throw e;
270+ } catch (ExecutionException e) {
271+ connection.closeAsync().force();
272+ throw e;
263273 } catch (RuntimeException e) {
264- connection.closeAsync().get();
274+ connection.closeAsync().force();
265275 throw e;
266276 }
267277 }