Revert last change. Parser is not thread-safe anyway
git-svn-id: https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/parser@1837220 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8fa207b..3d004cc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -23,9 +23,6 @@
<body>
<release version="2.0.0" date="in SVN">
- <action dev="tv" type="fix">
- Fix thread safety issues in BaseValueParser
- </action>
<action dev="tv" type="remove">
INCOMAPTIBLE: Remove dependency on fulcrum-upload.
All FileItems are now Parts.
diff --git a/src/java/org/apache/fulcrum/parser/BaseValueParser.java b/src/java/org/apache/fulcrum/parser/BaseValueParser.java
index b044c39..aa516f5 100644
--- a/src/java/org/apache/fulcrum/parser/BaseValueParser.java
+++ b/src/java/org/apache/fulcrum/parser/BaseValueParser.java
@@ -39,7 +39,6 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.fulcrum.pool.Recyclable;
/**
@@ -102,7 +101,7 @@
private Locale locale = Locale.getDefault();
/** The DateFormat to use for converting dates */
- private FastDateFormat dateFormat = FastDateFormat.getDateInstance(FastDateFormat.SHORT, locale);
+ private DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
/** The NumberFormat to use when converting floats and decimals */
private NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
@@ -221,7 +220,7 @@
public void setLocale(Locale l)
{
locale = l;
- setDateFormat(FastDateFormat.getDateInstance(FastDateFormat.SHORT, locale));
+ setDateFormat(DateFormat.getDateInstance(DateFormat.SHORT, locale));
setNumberFormat(NumberFormat.getNumberInstance(locale));
}
@@ -238,7 +237,7 @@
* Set the date format that will be used by this ValueParser.
*/
@Override
- public void setDateFormat(FastDateFormat df)
+ public void setDateFormat(DateFormat df)
{
dateFormat = df;
}
@@ -247,7 +246,7 @@
* Get the date format that will be used by this ValueParser.
*/
@Override
- public FastDateFormat getDateFormat()
+ public DateFormat getDateFormat()
{
return dateFormat;
}
@@ -279,8 +278,7 @@
@Override
public void add(String name, double value)
{
- NumberFormat nf = (NumberFormat) numberFormat.clone();
- add(name, nf.format(value));
+ add(name, numberFormat.format(value));
}
/**
@@ -616,9 +614,8 @@
if (StringUtils.isNotEmpty(value))
{
- NumberFormat nf = (NumberFormat) numberFormat.clone();
ParsePosition pos = new ParsePosition(0);
- Number number = nf.parse(value, pos);
+ Number number = numberFormat.parse(value, pos);
if (pos.getIndex() == value.length())
{
@@ -1383,23 +1380,7 @@
@Override
public Date getDate(String name)
{
- Date result = null;
- String value = StringUtils.trim(getString(name));
-
- if (StringUtils.isNotEmpty(value))
- {
- try
- {
- // Reject invalid dates.
- result = dateFormat.parse(value);
- }
- catch (ParseException e)
- {
- logConversionFailure(name, value, "Date");
- }
- }
-
- return result;
+ return getDate(name, dateFormat, null);
}
/**
diff --git a/src/java/org/apache/fulcrum/parser/ValueParser.java b/src/java/org/apache/fulcrum/parser/ValueParser.java
index ea38d1d..33fe869 100644
--- a/src/java/org/apache/fulcrum/parser/ValueParser.java
+++ b/src/java/org/apache/fulcrum/parser/ValueParser.java
@@ -27,9 +27,6 @@
import java.util.Locale;
import java.util.Set;
-import org.apache.commons.lang3.time.FastDateFormat;
-
-
/**
* ValueParser is a base interface for classes that need to parse
* name/value Parameters, for example GET/POST data or Cookies
@@ -99,12 +96,12 @@
/**
* Set the date format that will be used by this ValueParser.
*/
- void setDateFormat(FastDateFormat df);
+ void setDateFormat(DateFormat df);
/**
* Get the date format that will be used by this ValueParser.
*/
- FastDateFormat getDateFormat();
+ DateFormat getDateFormat();
/**
* Set the number format that will be used by this ValueParser.