summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2014-06-27 22:14:14 +0000
committerGordon Sim <gsim@apache.org>2014-06-27 22:14:14 +0000
commit014c7d30c12b4278319cd7aa68f3497893add5b2 (patch)
treea1ee762f409a42c9071305d42b6a4af27fbf7826 /qpid/cpp/src
parentfdaed2846c34f566aa35b5304f912bfd763358b8 (diff)
downloadqpid-python-014c7d30c12b4278319cd7aa68f3497893add5b2.tar.gz
QPID-5858: prevent leakage of old exception types
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1606258 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp16
-rw-r--r--qpid/cpp/src/tests/MessagingSessionTests.cpp19
2 files changed, 34 insertions, 1 deletions
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
index d99407112b..8c6eef6273 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
@@ -62,7 +62,21 @@ void SessionImpl::checkError()
{
ScopedLock l(lock);
qpid::client::SessionBase_0_10Access s(session);
- s.get()->assertOpen();
+ try {
+ s.get()->assertOpen();
+ } catch (const qpid::TransportFailure&) {
+ throw qpid::messaging::TransportFailure(std::string());
+ } catch (const qpid::framing::ResourceLimitExceededException& e) {
+ throw qpid::messaging::TargetCapacityExceeded(e.what());
+ } catch (const qpid::framing::UnauthorizedAccessException& e) {
+ throw qpid::messaging::UnauthorizedAccess(e.what());
+ } catch (const qpid::SessionException& e) {
+ throw qpid::messaging::SessionError(e.what());
+ } catch (const qpid::ConnectionException& e) {
+ throw qpid::messaging::ConnectionError(e.what());
+ } catch (const qpid::Exception& e) {
+ throw qpid::messaging::MessagingException(e.what());
+ }
}
bool SessionImpl::hasError()
diff --git a/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp
index d23619e846..0926765d78 100644
--- a/qpid/cpp/src/tests/MessagingSessionTests.cpp
+++ b/qpid/cpp/src/tests/MessagingSessionTests.cpp
@@ -1432,6 +1432,25 @@ QPID_AUTO_TEST_CASE(testCloseAndMultipleConcurrentFetches)
BOOST_CHECK(!fetcher.timedOut);
}
+QPID_AUTO_TEST_CASE(testSessionCheckError)
+{
+ MessagingFixture fix;
+ std::string queue();
+ Session session = fix.connection.createSession();
+ Sender sender = session.createSender("q; {create:always, node:{x-declare:{auto-delete:True, arguments:{qpid.max_count:1}}}}");
+ ScopedSuppressLogging sl;
+ for (uint i = 0; i < 2; ++i) {
+ sender.send(Message((boost::format("A_%1%") % (i+1)).str()));
+ }
+ try {
+ while (true) session.checkError();
+ } catch (const qpid::types::Exception&) {
+ //this is ok
+ } catch (const qpid::Exception&) {
+ BOOST_FAIL("Wrong exception type thrown");
+ }
+}
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests