From 6010eea9e51c08a784add179ef5539d2be64f48f Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Wed, 9 Feb 2011 00:02:21 +0000 Subject: QPID-3042 The createSession method in Connection.java now waits until the connection state == OPEN before it actually sends the session-attach on the wire. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1068696 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/transport/Connection.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java index fd19fa0512..ab9d4431a3 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -313,6 +313,17 @@ public class Connection extends ConnectionInvoker { synchronized (lock) { + Waiter w = new Waiter(lock, timeout); + while (w.hasTime() && state != OPEN && error == null) + { + w.await(); + } + + if (state != OPEN) + { + throw new ConnectionException("Timed out waiting for connection to be ready. Current state is :" + state); + } + Session ssn = _sessionFactory.newSession(this, name, expiry); sessions.put(name, ssn); map(ssn); -- cgit v1.2.1