8165215: Setting same UL tag multiple times matches wrong tagset
authorrehn
Fri, 02 Sep 2016 08:51:26 +0200
changeset 40913 072bdbb90c13
parent 40912 7f19457ea0fc
child 40915 7ca02bd6fbf6
8165215: Setting same UL tag multiple times matches wrong tagset Reviewed-by: mlarsson, rprotacio
hotspot/src/share/vm/logging/logTagLevelExpression.cpp
hotspot/src/share/vm/logging/logTagLevelExpression.hpp
hotspot/test/native/logging/test_logTagLevelExpression.cpp
--- a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp	Fri Sep 02 01:39:47 2016 +0000
+++ b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp	Fri Sep 02 08:51:26 2016 +0200
@@ -164,7 +164,14 @@
         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);
 
--- a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp	Fri Sep 02 01:39:47 2016 +0000
+++ b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp	Fri Sep 02 08:51:26 2016 +0200
@@ -59,9 +59,15 @@
     _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) {
--- a/hotspot/test/native/logging/test_logTagLevelExpression.cpp	Fri Sep 02 01:39:47 2016 +0000
+++ b/hotspot/test/native/logging/test_logTagLevelExpression.cpp	Fri Sep 02 08:51:26 2016 +0200
@@ -33,7 +33,7 @@
   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",