[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-web/master] Make GetTor stats file parsing more robust.



commit bfd2c04cb8ec972e9e71036f6c679c3ac06d9c73
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed May 2 15:02:54 2012 +0200

    Make GetTor stats file parsing more robust.
---
 src/org/torproject/ernie/cron/GetTorProcessor.java |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/org/torproject/ernie/cron/GetTorProcessor.java b/src/org/torproject/ernie/cron/GetTorProcessor.java
index 0c5325d..2b5d67a 100644
--- a/src/org/torproject/ernie/cron/GetTorProcessor.java
+++ b/src/org/torproject/ernie/cron/GetTorProcessor.java
@@ -53,13 +53,22 @@ public class GetTorProcessor {
           continue;
         }
         Map<String, Integer> obs = new HashMap<String, Integer>();
-        data.put(date, obs);
         for (int i = 2; i < parts.length; i++) {
-          String key = parts[i].split(":")[0].toLowerCase();
-          Integer value = new Integer(parts[i].split(":")[1]);
+          String[] partParts = parts[i].split(":");
+          if (partParts.length != 2) {
+            logger.warning("Illegal line in GetTor stats file: '" + line
+                + "'.  Skipping.");
+            obs = null;
+            break;
+          }
+          String key = partParts[0].toLowerCase();
+          Integer value = new Integer(partParts[1]);
           columns.add(key);
           obs.put(key, value);
         }
+        if (obs != null) {
+          data.put(date, obs);
+        }
       }
       br.close();
     } catch (IOException e) {

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits