We are trying to get ready to release a beta version of the software I'm working on.. so part of getting ready for that was to try set up some stress tests and hit the server with multiple requests for the same page....
Not sure exactly how many it is taking but we are getting the following exception.
2005-06-10 13:20:23 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
java.lang.NumberFormatException: For input string: "200044.E2000444E"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1207)
at java.lang.Double.parseDouble(Double.java:220)
at java.text.DigitList.getDouble(DigitList.java:127)
at java.text.DecimalFormat.parse(DecimalFormat.java:1070)
at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1386)
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1156)
at java.text.DateFormat.parse(DateFormat.java:333)
at com.xxxxx.xxxxx.struts.adapter.BrowseBaseAdapter.formatYyyyMMddToLocaleStr(BrowseBaseAdapter.java:194)
I can only assume that something was not thread safe and somehow something is getting confused....
this is the method that produced the error and the code that it runs.
I know absolutely nothing about making something thread safe.... can anyone give me good link to refer to or point something out in the below code that might be a no no.
private static final SimpleDateFormat xxxxxxxxDateFormat =
new SimpleDateFormat("yyyyMMdd");
protected String formatYyyyMMddToLocaleStr(
String xxxxxxxxDt,
Locale locale) {
String result = "";
if ( xxxxxxxxDt != null && xxxxxxxxDt.length() == 8) {
try {
Date tempDate = xxxxxxxxDateFormat.parse( xxxxxxxxDt);
result = javaDataTypeToString(tempDate, locale);
} catch (ParseException ex) {
}
}
return result;
}
public String javaDataTypeToString(Object data, Locale locale) {
String returnType = data.getClass().getName();
String result = null;
if (returnType.equals("java.lang.String")) {
result = (String) data;
} else if (returnType.equals("java.lang.Float")) {
NumberFormat formatter = NumberFormat.getNumberInstance(locale);
formatter.setMaximumFractionDigits(6);
formatter.setGroupingUsed(false);
result = formatter.format((Float) data);
} else if (returnType.equals("java.lang.Double")
|| returnType.equals("java.math.BigDecimal")) {
NumberFormat formatter = NumberFormat.getNumberInstance(locale);
formatter.setMaximumFractionDigits(13);
formatter.setGroupingUsed(false);
StringBuffer buffer = new StringBuffer();
result = formatter.format(data, buffer, new FieldPosition(0))
.toString();
} else if (returnType.equals("java.lang.Integer")) {
Integer inte = (Integer) data;
int intVal = inte.intValue();
if (intVal != 0)
result = String.valueOf(intVal);
else
result = "";
} else if (returnType.equals("java.util.Date")) {
java.util.Date date = (java.util.Date) data;
SimpleDateFormat dateFormatter = getDatePattern(locale);
result = dateFormatter.format(date);
} else if (returnType.equals("com.sungard.stnweb.utility.Time")) {
Time time = (Time) data;
result = time.asString();
} else if (returnType.equals("java.lang.Boolean")) {
Boolean dataBool = (Boolean) data;
if (dataBool.booleanValue())
result = "1";
else
result = "";
}
return result;