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

[tor-commits] [metrics-web/master] Make DirectoryListing server locale consistent.



commit 34dd60d34394a748143cf0f4dfaf5163fc6c49c3
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Mon Dec 4 11:14:44 2017 +0000

    Make DirectoryListing server locale consistent.
    
    Make testFormatBytes pass on servers with a locale not using a decimal dot.
---
 src/main/java/org/torproject/metrics/web/DirectoryListing.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/torproject/metrics/web/DirectoryListing.java b/src/main/java/org/torproject/metrics/web/DirectoryListing.java
index 6dd09e4..b83cedb 100644
--- a/src/main/java/org/torproject/metrics/web/DirectoryListing.java
+++ b/src/main/java/org/torproject/metrics/web/DirectoryListing.java
@@ -10,6 +10,7 @@ import org.torproject.descriptor.index.IndexNode;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -84,7 +85,8 @@ public class DirectoryListing extends HashMap<String, List<String[]>>
     }
     int exp = (int) (Math.log(bytes) / Math.log(1024));
     char pre = "KMGTPE".charAt(exp - 1);
-    return String.format("%.1f %siB", bytes / Math.pow(1024, exp), pre);
+    return String
+        .format(Locale.US, "%.1f %siB", bytes / Math.pow(1024, exp), pre);
   }
 }
 



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