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