kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 47df60f15f7507869cad3fb057aafc4285be968acbafcd4d8842156ddb3dce94 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-12-18 11:02 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-12-19 00:16 +01:00 |
| Parents | a3cf912d769e |
1 file changed
modified driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java +17 −4
| @@ -88,11 +88,17 @@ | ||
| 88 | 88 | Thread.currentThread().interrupt(); |
| 89 | 89 | // If asked to interrupt, we can skip opening core connections, the pool will still work. |
| 90 | 90 | // But we ignore otherwise cause I'm not sure we can do much better currently. |
| 91 | + } catch (ConnectionException e) { | |
| 92 | + forceClose(l); | |
| 93 | + throw e; | |
| 94 | + } catch (UnsupportedProtocolVersionException e) { | |
| 95 | + forceClose(l); | |
| 96 | + throw e; | |
| 97 | + } catch (ClusterNameMismatchException e) { | |
| 98 | + forceClose(l); | |
| 99 | + throw e; | |
| 91 | 100 | } catch (RuntimeException e) { |
| 92 | - // Rethrow but make sure to properly close the connections in our temporary list. | |
| 93 | - for (PooledConnection connection : l) { | |
| 94 | - connection.closeAsync().force(); | |
| 95 | - } | |
| 101 | + forceClose(l); | |
| 96 | 102 | throw e; |
| 97 | 103 | } |
| 98 | 104 | this.connections = new CopyOnWriteArrayList<PooledConnection>(l); |
| @@ -101,6 +107,13 @@ | ||
| 101 | 107 | logger.trace("Created connection pool to host {}", host); |
| 102 | 108 | } |
| 103 | 109 | |
| 110 | + // Clean up if we got an error at construction time but still created part of the core connections | |
| 111 | + private void forceClose(List<PooledConnection> l) { | |
| 112 | + for (PooledConnection connection : l) { | |
| 113 | + connection.closeAsync().force(); | |
| 114 | + } | |
| 115 | + } | |
| 116 | + | |
| 104 | 117 | private PoolingOptions options() { |
| 105 | 118 | return manager.configuration().getPoolingOptions(); |
| 106 | 119 | } |