Stop reusing the Cluster when waiting for Cassandra to start

See gh-10516
This commit is contained in:
Andy Wilkinson 2018-01-08 14:07:38 +00:00
parent 927003e0b7
commit c7f5f0735d
1 changed files with 8 additions and 6 deletions

View File

@ -109,19 +109,20 @@ public class CassandraDataAutoConfigurationIntegrationTests {
@Override
protected void waitUntilReady() {
super.waitUntilReady();
Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
try {
Unreliables.retryUntilTrue((int) this.startupTimeout.getSeconds(),
TimeUnit.SECONDS, checkConnection(cluster));
TimeUnit.SECONDS, checkConnection());
}
catch (TimeoutException e) {
throw new IllegalStateException();
catch (TimeoutException ex) {
throw new IllegalStateException(ex);
}
}
private Callable<Boolean> checkConnection(Cluster cluster) {
private Callable<Boolean> checkConnection() {
return () -> {
try {
try (Cluster cluster = Cluster.builder().addContactPoint("localhost")
.build()) {
cluster.connect();
return true;
}
@ -130,6 +131,7 @@ public class CassandraDataAutoConfigurationIntegrationTests {
}
};
}
}
}