changeset 13534:ac5a73f93b55

8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale. Reviewed-by: simonis, goetz, dholmes Contributed-by: Arno Zeller <arno.zeller@sap.com>
author goetz
date Sun, 20 Aug 2017 22:20:42 -0400
parents 8c39c9157c17
children 4d2fded7bd7d 680ee8757c16
files test/serviceability/tmtools/jstat/utils/JstatResults.java
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/serviceability/tmtools/jstat/utils/JstatResults.java	Fri Aug 18 14:54:43 2017 -0700
+++ b/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());
+        }
     }
 
     /**