8165215: Setting same UL tag multiple times matches wrong tagset

Reviewed-by: mlarsson, rprotacio
This commit is contained in:
Robbin Ehn 2016-09-02 08:51:26 +02:00
parent 8b9c8fc1c4
commit 3e07dc6611
3 changed files with 16 additions and 3 deletions

View File

@ -164,7 +164,14 @@ bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) {
success = false;
break;
}
add_tag(tag);
if (!add_tag(tag)) {
if (errstream != NULL) {
errstream->print_cr("Tag combination have duplicate tag '%s' in what-expression.",
cur_tag);
}
success = false;
break;
}
cur_tag = plus_pos + 1;
} while (plus_pos != NULL);

View File

@ -59,9 +59,15 @@ class LogTagLevelExpression : public StackObj {
_ntags = 0;
}
void add_tag(LogTagType tag) {
bool add_tag(LogTagType tag) {
assert(_ntags < LogTag::MaxTags, "Can't have more tags than MaxTags!");
for (size_t i = 0; i < _ntags; i++) {
if (_tags[_ncombinations][i] == tag) {
return false;
}
}
_tags[_ncombinations][_ntags++] = tag;
return true;
}
void set_level(LogLevelType level) {

View File

@ -33,7 +33,7 @@ TEST(LogTagLevelExpression, parse) {
const char* invalid_substr[] = {
"=", "+", " ", "+=", "+=*", "*+", " +", "**", "++", ".", ",", ",," ",+",
" *", "all+", "all*", "+all", "+all=Warning", "==Info", "=InfoWarning",
"BadTag+", "logging++", "logging*+", ",=", "gc+gc+gc+gc+gc+gc"
"BadTag+", "logging++", "logging*+", ",=", "gc+gc+"
};
const char* valid_expression[] = {
"all", "gc", "gc,logging", "gc+logging", "logging+gc", "logging+gc,gc", "logging+gc*", "gc=trace",