no jira - fix leak of connection in case of failed attempt to connect
This commit is contained in:
parent
fa439375e9
commit
824eaf7a69
|
@ -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 ");
|
||||||
|
|
Loading…
Reference in New Issue