kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 58739bfde29aacf486cd15c8757b93cf1dc94e66f1e220de03e22980d9cde2f3 |
|---|---|
| Author | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-24 15:05 +01:00 |
| Committer | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-24 15:05 +01:00 |
| Parents | 6a3c42810091, 833cc0dfd10d |
2 files changed
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +6 −1
| @@ -153,7 +153,12 @@ | ||
| 153 | 153 | */ |
| 154 | 154 | public Session connect(String keyspace) { |
| 155 | 155 | SessionManager session = (SessionManager)connect(); |
| 156 | - session.setKeyspace(keyspace); | |
| 156 | + try { | |
| 157 | + session.setKeyspace(keyspace); | |
| 158 | + } catch (RuntimeException e) { | |
| 159 | + session.shutdown(); | |
| 160 | + throw e; | |
| 161 | + } | |
| 157 | 162 | return session; |
| 158 | 163 | } |
| 159 | 164 |
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +4 −0
| @@ -219,7 +219,11 @@ | ||
| 219 | 219 | refreshSchema(connection, null, null, cluster); |
| 220 | 220 | return connection; |
| 221 | 221 | } catch (BusyConnectionException e) { |
| 222 | + connection.close(Long.MAX_VALUE, TimeUnit.MILLISECONDS); | |
| 222 | 223 | throw new DriverInternalError("Newly created connection should not be busy"); |
| 224 | + } catch (RuntimeException e) { | |
| 225 | + connection.close(Long.MAX_VALUE, TimeUnit.MILLISECONDS); | |
| 226 | + throw e; | |
| 223 | 227 | } |
| 224 | 228 | } |
| 225 | 229 |