8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
authorgoetz
Sun, 20 Aug 2017 22:20:42 -0400
changeset 46827 8d2f07a78ac7
parent 46826 dae7992b1615
child 46828 19b0b4ceb75d
child 46829 997b9221c2a3
8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale. Reviewed-by: simonis, goetz, dholmes Contributed-by: Arno Zeller <arno.zeller@sap.com>
hotspot/test/serviceability/tmtools/jstat/utils/JstatResults.java
--- a/hotspot/test/serviceability/tmtools/jstat/utils/JstatResults.java	Fri Aug 18 14:54:43 2017 -0700
+++ b/hotspot/test/serviceability/tmtools/jstat/utils/JstatResults.java	Sun Aug 20 22:20:42 2017 -0400
@@ -23,6 +23,9 @@
 package utils;
 
 import common.ToolResults;
+import java.text.NumberFormat;
+import java.text.ParseException;
+
 
 /**
  * Results of running the jstat tool Concrete subclasses will detail the jstat
@@ -55,7 +58,13 @@
      */
     public float getFloatValue(String name) {
         int valueNdx = new StringOfValues(getStdoutLine(0)).getIndex(name);
-        return Float.valueOf(new StringOfValues(getStdoutLine(1)).getValue(valueNdx));
+        // Let the parsing use the current locale format.
+        try {
+            return NumberFormat.getInstance().parse(new StringOfValues(getStdoutLine(1)).getValue(valueNdx)).floatValue();
+        } catch (ParseException e) {
+            throw new NumberFormatException(e.getMessage());
+        }
+
     }
 
     /**
@@ -66,7 +75,11 @@
      */
     public int getIntValue(String name) {
         int valueNdx = new StringOfValues(getStdoutLine(0)).getIndex(name);
-        return Integer.valueOf(new StringOfValues(getStdoutLine(1)).getValue(valueNdx));
+        try {
+            return NumberFormat.getInstance().parse(new StringOfValues(getStdoutLine(1)).getValue(valueNdx)).intValue();
+        } catch (ParseException e) {
+            throw new NumberFormatException(e.getMessage());
+        }
     }
 
     /**