summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/broker/QueuePolicy.cpp16
-rw-r--r--cpp/src/tests/QueuePolicyTest.cpp18
2 files changed, 29 insertions, 5 deletions
diff --git a/cpp/src/qpid/broker/QueuePolicy.cpp b/cpp/src/qpid/broker/QueuePolicy.cpp
index c1d979ac33..f311ea8321 100644
--- a/cpp/src/qpid/broker/QueuePolicy.cpp
+++ b/cpp/src/qpid/broker/QueuePolicy.cpp
@@ -123,17 +123,23 @@ uint32_t QueuePolicy::getCapacity(const FieldTable& settings, const std::string&
int32_t result = 0;
if (!v) return defaultValue;
- if (v->convertsTo<int>()) {
+ if (v->getType() == 0x23) {
+ QPID_LOG(debug, "Value for " << key << " specified as float: " << v->get<float>());
+ } else if (v->getType() == 0x33) {
+ QPID_LOG(debug, "Value for " << key << " specified as double: " << v->get<double>());
+ } else if (v->convertsTo<int>()) {
result = v->get<int>();
+ QPID_LOG(debug, "Got integer value for " << key << ": " << result);
if (result >= 0) return result;
- }
- else {
- string s(v->get<string>()); // I assume anything can be converted to a string
+ } else if (v->convertsTo<string>()) {
+ string s(v->get<string>());
+ QPID_LOG(debug, "Got string value for " << key << ": " << s);
std::istringstream convert(s);
if (convert >> result && result >= 0) return result;
}
- throw InvalidArgumentException(QPID_MSG("Cannot convert " << key << " to unsigned integer"));
+ QPID_LOG(warning, "Cannot convert " << key << " to unsigned integer, using default (" << defaultValue << ")");
+ return defaultValue;
}
std::string QueuePolicy::getType(const FieldTable& settings)
diff --git a/cpp/src/tests/QueuePolicyTest.cpp b/cpp/src/tests/QueuePolicyTest.cpp
index 5992151e46..90af9c7dd9 100644
--- a/cpp/src/tests/QueuePolicyTest.cpp
+++ b/cpp/src/tests/QueuePolicyTest.cpp
@@ -378,6 +378,24 @@ QPID_AUTO_TEST_CASE(testPolicyFailureOnCommit)
BOOST_CHECK_THROW(f.session.txCommit(), InternalErrorException);
}
+QPID_AUTO_TEST_CASE(testCapacityConversion)
+{
+ FieldTable args;
+ args.setString("qpid.max_count", "5");
+
+ ProxySessionFixture f;
+ std::string q("q");
+ f.session.queueDeclare(arg::queue=q, arg::exclusive=true, arg::autoDelete=true, arg::arguments=args);
+ for (int i = 0; i < 5; i++) {
+ f.session.messageTransfer(arg::content=client::Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), q));
+ }
+ try {
+ ScopedSuppressLogging sl; // Suppress messages for expected errors.
+ f.session.messageTransfer(arg::content=client::Message("Message_6", q));
+ BOOST_FAIL("expecting ResourceLimitExceededException.");
+ } catch (const ResourceLimitExceededException&) {}
+}
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests