maoling commented on a change in pull request #934: ZOOKEEPER-3301:Enforce the 
quota limit
URL: https://github.com/apache/zookeeper/pull/934#discussion_r383070517
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/StatsTrack.java
 ##########
 @@ -34,22 +45,23 @@
     public StatsTrack() {
         this(null);
     }
+
     /**
-     * the stat string should be of the form count=int,bytes=long
-     * if stats is called with null the count and bytes are initialized
-     * to -1.
-     * @param stats the stat string to be intialized with
+     * the stat string should be of the form key1str=long,key2str=long,..
+     * where either , or ; are valid separators
+     * uninitialized values are returned as -1
+     * @param stats the stat string to be initialized with
      */
     public StatsTrack(String stats) {
-        if (stats == null) {
-            stats = "count=-1,bytes=-1";
+        this.stats.clear();
+        if (stats == null || stats.length() == 0) {
+            return;
         }
-        String[] split = stats.split(",");
-        if (split.length != 2) {
-            throw new IllegalArgumentException("invalid string " + stats);
+        String[] keyValuePairs = stats.split("[,;]+");
 
 Review comment:
   Great catch

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to