Skip to content

Commit 3f51a52

Browse files
authored
Feat[bmqt]: Limit queue names to 64 characters (#823)
Signed-off-by: Christopher Beard <cbeard9@bloomberg.net>
1 parent d2d5098 commit 3f51a52

3 files changed

Lines changed: 13 additions & 31 deletions

File tree

src/groups/bmq/bmqt/bmqt_uri.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,13 @@ int UriParser::parse(Uri* result,
264264
{
265265
enum RcEnum {
266266
// Value for the various RC error categories
267-
rc_SUCCESS = 0,
268-
rc_INVALID_FORMAT = -1,
269-
rc_BAD_QUERY = -2,
270-
rc_MISSING_DOMAIN = -3,
271-
rc_MISSING_QUEUE = -4,
272-
rc_MISSING_TIER = -5
267+
rc_SUCCESS = 0,
268+
rc_INVALID_FORMAT = -1,
269+
rc_BAD_QUERY = -2,
270+
rc_MISSING_DOMAIN = -3,
271+
rc_MISSING_QUEUE = -4,
272+
rc_MISSING_TIER = -5,
273+
rc_QUEUE_NAME_TOO_LONG = -6
273274
};
274275

275276
enum {
@@ -384,20 +385,11 @@ int UriParser::parse(Uri* result,
384385
}
385386

386387
if (result->d_path.length() > Uri::k_QUEUENAME_MAX_LENGTH) {
387-
// TBD: Convert to a real error once certified all active queues are
388-
// within the limit. When converting to an error, add test cases
389-
// in the test driver.
390-
BSLMT_ONCE_DO
391-
{
392-
bmqu::MemOutStream os;
393-
os << "The queue name part of '" << uriString << "' is exceeding "
394-
<< "the maximum size limit of " << Uri::k_QUEUENAME_MAX_LENGTH
395-
<< ". This is only a warning at the moment, but this limit "
396-
<< "will soon be enforced and queue URI will be rejected!";
397-
bsl::cerr << "BMQALARM [INVALID_QUEUE_NAME]: " << os.str() << '\n'
398-
<< bsl::flush;
399-
BALL_LOG_ERROR << os.str();
388+
if (errorDescription) {
389+
*errorDescription = "queue name exceeds 64 characters";
400390
}
391+
result->reset();
392+
return rc_QUEUE_NAME_TOO_LONG;
401393
}
402394

403395
// Success

src/groups/bmq/bmqt/bmqt_uri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class Uri {
228228

229229
/// Implicit constructor of this object from the specified `uri` string
230230
/// using the optionally specified `allocator`. If the `uri` input
231-
/// string doesn't not represent a valid URI, this object is left in an
231+
/// string does not represent a valid URI, this object is left in an
232232
/// invalid state (isValid() will return false).
233233
Uri(const bsl::string& uri,
234234
bslma::Allocator* allocator = 0); // IMPLICIT

src/groups/bmq/bmqt/bmqt_uri.t.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -642,17 +642,7 @@ static void test7_testLongUri()
642642

643643
bmqt::Uri obj(stream.str(), bmqtst::TestHelperUtil::allocator());
644644

645-
BMQTST_ASSERT_EQ(observer.records().size(), 1U);
646-
647-
BMQTST_ASSERT_EQ(observer.records()[0].fixedFields().severity(),
648-
ball::Severity::e_ERROR);
649-
650-
BMQTST_ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch(
651-
observer.records()[0],
652-
pathStr.data(),
653-
bmqtst::TestHelperUtil::allocator()));
654-
655-
BMQTST_ASSERT_EQ(obj.isValid(), true);
645+
BMQTST_ASSERT_EQ(obj.isValid(), false);
656646

657647
bmqt::UriParser::shutdown();
658648
}

0 commit comments

Comments
 (0)