no jira - fix leak of connection in case of failed attempt to connect

This commit is contained in:
gtully 2021-09-23 17:03:49 +01:00
parent fa439375e9
commit 824eaf7a69
1 changed files with 1 additions and 2 deletions

View File

@ -135,8 +135,7 @@ public class ServerUtil {
public static boolean waitForServerToStart(String uri, String username, String password, long timeout) throws InterruptedException {
long realTimeout = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < realTimeout) {
try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) {
cf.createConnection(username, password).close();
try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null); Connection c = cf.createConnection(username, password)) {
System.out.println("server " + uri + " started");
} catch (Exception e) {
System.out.println("awaiting server " + uri + " start at ");