8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
Reviewed-by: simonis, goetz, dholmes
Contributed-by: Arno Zeller <arno.zeller@sap.com>
--- 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());
+ }
}
/**