[Geoserver-devel] [jira] Created: (GEOS-2931) TimeKvpParser.getDate() is not thread safe -- WMS request causes NumberFormatException

TimeKvpParser.getDate() is not thread safe -- WMS request causes NumberFormatException
---------------------------------------------------------------------------------------

                 Key: GEOS-2931
                 URL: http://jira.codehaus.org/browse/GEOS-2931
             Project: GeoServer
          Issue Type: Bug
    Affects Versions: 1.7.1
         Environment: RHEL3, Java 1.6.0_11, JBoss 4.0.3SP1, two Intel Xeon CPU 2.80GHz (appears as 4 processors)
            Reporter: Ryan Hofschneider
            Assignee: Andrea Aime
            Priority: Critical

Making a WMS call to a layer that is backed by PostgreSQL/PostGIS that contains a non-NULL date column on a can result in a NumberFormatException with various exception messages:

java.lang.NumberFormatException: multiple points
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1084)
    at java.lang.Double.parseDouble(Double.java:510)
    at java.text.DigitList.getDouble(DigitList.java:151)
    at java.text.DecimalFormat.parse(DecimalFormat.java:1303)
    at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1538)
    at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1263)
    at org.geoserver.ows.kvp.TimeKvpParser.getDate(TimeKvpParser.java:133)
    at org.geoserver.ows.kvp.TimeKvpParser.parse(TimeKvpParser.java:93)
    at org.geoserver.ows.util.KvpUtils.parse(KvpUtils.java:471)
    at org.geoserver.ows.Dispatcher.parseKVP(Dispatcher.java:1049)
    <snip>

or for example:
java.lang.NumberFormatException: For input string: ".330E"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Long.parseLong(Long.java:403)
    at java.lang.Long.parseLong(Long.java:461)
    at java.text.DigitList.getLong(DigitList.java:177)
    at java.text.DecimalFormat.parse(DecimalFormat.java:1298)
    at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1874)
    at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1263)
    at org.geoserver.ows.kvp.TimeKvpParser.getDate(TimeKvpParser.java:133)
    at org.geoserver.ows.kvp.TimeKvpParser.parse(TimeKvpParser.java:93)
    at org.geoserver.ows.util.KvpUtils.parse(KvpUtils.java:471)
    at org.geoserver.ows.Dispatcher.parseKVP(Dispatcher.java:1049)
    <snip>

(The input string value reported in the above trace will vary from call to call)

These exception traces are indicative of SimpleDateFormat being used simultaneously by multiple threads:
http://forums.sun.com/thread.jspa?threadID=5343210
http://forums.sun.com/thread.jspa?threadID=497693
(above thread mentions Intel hyperthreading as a trigger)

SimpleDateFormat is not thread safe, but it appears that TimeKvpParser caches SimpleDateFormat instances, and GeoServerExtensions has a static hash map that maintains an instance of TimeKvpParser.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira