kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 833cc0dfd10ddfbf6d51d66402841df91daf70c13b5ab5841a82f6a29c2a4e68 |
|---|---|
| Author | Shao-Chuan Wang <shaochuan.wang@bloomreach.com> · 2014-02-09 23:35 -08:00 |
| Committer | Shao-Chuan Wang <shaochuan.wang@bloomreach.com> · 2014-02-09 23:35 -08:00 |
| Parents | ffed01c5e379 |
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 |