From 25d3e82cefe8512c7066a5a9f07400f65db36e2e Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Wed, 10 Oct 2007 17:15:59 +0000 Subject: QPID-632 : The lack of AMQNoConsumersException on the connection may be due to the exception list in ExceptionMonitor not being thread safe. Synchronized method calls to ensure atomic access. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@583548 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/test/framework/ExceptionMonitor.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'java') diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java b/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java index 34274c827c..9f1207202e 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/ExceptionMonitor.java @@ -52,7 +52,7 @@ public class ExceptionMonitor implements ExceptionListener * * @param e The exception to record. */ - public void onException(JMSException e) + public synchronized void onException(JMSException e) { log.debug("public void onException(JMSException e): called", e); @@ -64,7 +64,7 @@ public class ExceptionMonitor implements ExceptionListener * * @return true if no exceptions have been received, false otherwise. */ - public boolean assertNoExceptions() + public synchronized boolean assertNoExceptions() { return exceptions.isEmpty(); } @@ -74,7 +74,7 @@ public class ExceptionMonitor implements ExceptionListener * * @return true if exactly one exception been received, false otherwise. */ - public boolean assertOneJMSException() + public synchronized boolean assertOneJMSException() { return exceptions.size() == 1; } @@ -85,7 +85,7 @@ public class ExceptionMonitor implements ExceptionListener * @return true if exactly one exception, with a linked cause of the specified type, been received, * false otherwise. */ - public boolean assertOneJMSExceptionWithLinkedCause(Class aClass) + public synchronized boolean assertOneJMSExceptionWithLinkedCause(Class aClass) { if (exceptions.size() == 1) { @@ -107,7 +107,7 @@ public class ExceptionMonitor implements ExceptionListener * * @return The number of exceptions held by this monitor. */ - public int size() + public synchronized int size() { return exceptions.size(); } @@ -115,9 +115,9 @@ public class ExceptionMonitor implements ExceptionListener /** * Clears the record of received exceptions. */ - public void reset() + public synchronized void reset() { - exceptions = new ArrayList(); + exceptions = new ArrayList(); } /** @@ -126,7 +126,7 @@ public class ExceptionMonitor implements ExceptionListener * * @return A string containing a dump of the stack traces of all exceptions. */ - public String toString() + public synchronized String toString() { String result = "ExceptionMonitor: holds " + exceptions.size() + " exceptions.\n\n"; -- cgit v1.2.1