diff options
author | Andrew Donald Kennedy <grkvlt@apache.org> | 2010-08-13 16:19:28 +0000 |
---|---|---|
committer | Andrew Donald Kennedy <grkvlt@apache.org> | 2010-08-13 16:19:28 +0000 |
commit | c700093f4294bb1bcda42f3fc1982dcc57dc44da (patch) | |
tree | 5fc93a03fed2274513e7da3123258d12f58ffbcd /java/common | |
parent | cf96b23f687c379bd71f465c837379b0966c2184 (diff) | |
download | qpid-python-c700093f4294bb1bcda42f3fc1982dcc57dc44da.tar.gz |
QPID-2657: Correct handling of sync on 0-10 client session for exceptions
AMQSession_0_10 is modified to contain a pair of get/set methods for the current
exception, using the set method to post the exception to the listener. The sync
method will now throw an exception if one has occurred and all other methods
that used to call sync()/getCurrentException() can just call sync(0 and get the
expected behaviour.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@985262 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
5 files changed, 42 insertions, 30 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/java/common/src/main/java/org/apache/qpid/transport/Connection.java index ed6f00a51c..13b8e461d4 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -56,7 +56,7 @@ public class Connection extends ConnectionInvoker implements Receiver<ProtocolEvent>, Sender<ProtocolEvent> { - private static final Logger log = Logger.get(Connection.class); + protected static final Logger log = Logger.get(Connection.class); public enum State { NEW, CLOSED, OPENING, OPEN, CLOSING, CLOSE_RCVD } diff --git a/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java index 29389df99a..88dd2d6afa 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java +++ b/java/common/src/main/java/org/apache/qpid/transport/ConnectionDelegate.java @@ -99,5 +99,4 @@ public abstract class ConnectionDelegate ssn.closed(); } } - } diff --git a/java/common/src/main/java/org/apache/qpid/transport/Session.java b/java/common/src/main/java/org/apache/qpid/transport/Session.java index 5e40527c2f..9b84ff422b 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/Session.java +++ b/java/common/src/main/java/org/apache/qpid/transport/Session.java @@ -280,7 +280,7 @@ public class Session extends SessionInvoker { if (m != null) { - System.out.println(m); + log.debug("%s", m); } } } @@ -732,8 +732,7 @@ public class Session extends SessionInvoker Waiter w = new Waiter(commands, timeout); while (w.hasTime() && state != CLOSED && lt(maxComplete, point)) { - log.debug("%s waiting for[%d]: %d, %s", this, point, - maxComplete, commands); + log.debug("%s waiting for[%d]: %d, %s", this, point, maxComplete, commands); w.await(); } @@ -741,16 +740,23 @@ public class Session extends SessionInvoker { if (state != CLOSED) { - throw new SessionException - (String.format - ("timed out waiting for sync: complete = %s, point = %s", maxComplete, point)); + throw new SessionException( + String.format("timed out waiting for sync: complete = %s, point = %s", + maxComplete, point)); + } + else + { + ExecutionException ee = getException(); + if (ee != null) + { + throw new SessionException(ee); + } } } } } - private Map<Integer,ResultFuture<?>> results = - new HashMap<Integer,ResultFuture<?>>(); + private Map<Integer,ResultFuture<?>> results = new HashMap<Integer,ResultFuture<?>>(); private ExecutionException exception = null; void result(int command, Struct result) @@ -769,9 +775,8 @@ public class Session extends SessionInvoker { if (exception != null) { - throw new IllegalStateException - (String.format - ("too many exceptions: %s, %s", exception, exc)); + throw new IllegalStateException( + String.format("too many exceptions: %s, %s", exception, exc)); } exception = exc; } @@ -849,8 +854,8 @@ public class Session extends SessionInvoker } else { - throw new SessionException - (String.format("%s timed out waiting for result: %s", + throw new SessionException( + String.format("%s timed out waiting for result: %s", Session.this, this)); } } @@ -961,5 +966,4 @@ public class Session extends SessionInvoker { return String.format("ssn:%s", name); } - } diff --git a/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java index 15539c1d07..5d8e4d5565 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java +++ b/java/common/src/main/java/org/apache/qpid/transport/SessionDelegate.java @@ -33,11 +33,15 @@ public class SessionDelegate extends MethodDelegate<Session> implements ProtocolDelegate<Session> { - private static final Logger log = Logger.get(SessionDelegate.class); + protected static final Logger log = Logger.get(SessionDelegate.class); - public void init(Session ssn, ProtocolHeader hdr) { } + public void init(Session ssn, ProtocolHeader hdr) + { + log.warn("INIT: [%s] %s", ssn, hdr); + } - public void control(Session ssn, Method method) { + public void control(Session ssn, Method method) + { method.dispatch(ssn, this); } @@ -50,7 +54,10 @@ public class SessionDelegate } } - public void error(Session ssn, ProtocolError error) { } + public void error(Session ssn, ProtocolError error) + { + log.warn("ERROR: [%s] %s", ssn, error); + } public void handle(Session ssn, Method method) { @@ -195,9 +202,11 @@ public class SessionDelegate public void closed(Session session) { + log.warn("CLOSED: [%s]", session); } public void detached(Session session) - { + { + log.warn("DETACHED: [%s]", session); } } diff --git a/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java b/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java index bdd3a0c93b..375a326654 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java +++ b/java/common/src/test/java/org/apache/qpid/transport/ConnectionTest.java @@ -424,10 +424,6 @@ public class ConnectionTest extends QpidTestCase implements SessionListener } } - /** - * The 0-10 {@code executionSync} command should set the exception status in the session, - * so that the client session object can then throw it as an {@link AMQException}. - */ public void testExecutionExceptionSync() throws Exception { startServer(); @@ -436,11 +432,15 @@ public class ConnectionTest extends QpidTestCase implements SessionListener conn.connect("localhost", port, null, "guest", "guest"); Session ssn = conn.createSession(); send(ssn, "EXCP 0", true); - ExecutionException before = ssn.getException(); - assertNull("There should not be an exception stored in the session", before); - ssn.sync(); - ExecutionException after = ssn.getException(); - assertNotNull("There should be an exception stored in the session", after); + try + { + ssn.sync(); + fail("this should have failed"); + } + catch (SessionException exc) + { + assertNotNull(exc.getException()); + } } } |