tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Khitrenovich" <khitrenov...@gmail.com>
Subject Thread safety issues in org.apache.catalina.util.CookieTools
Date Tue, 11 Nov 2008 13:12:15 GMT
Hi all,

We are using IPlanet 6.1 web server, that is based on Catalina 4.1
container. Recently we've run into strange exceptions on Catalina level.
After examining stack trace and relevant code, I see that the problem
originates in non-synchronized usage of static SimpleDateFormat variables
from DateTool class by CookieTools.getCookieHeaderValue() function.
According to JDK documentation, "Date formats are not synchronized. It is
recommended to create separate format instances for each thread. If multiple
threads access a format concurrently, it must be synchronized externally."

Sample stack trace:

java.lang.ArrayIndexOutOfBoundsException: 466
        at
sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:436)
        at
java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2081)
        at
java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1996)
        at java.util.Calendar.setTimeInMillis(Calendar.java:1066)
        at java.util.Calendar.setTime(Calendar.java:1032)
        at java.text.SimpleDateFormat.format(SimpleDateFormat.java:785)
        at java.text.SimpleDateFormat.format(SimpleDateFormat.java:778)
        at
org.apache.catalina.util.CookieTools.getCookieHeaderValue(CookieTools.java:150)
        at
org.apache.catalina.util.CookieTools.getCookieHeaderValue(CookieTools.java:100)
        at
com.iplanet.ias.web.connector.nsapi.NSAPIResponse.sendHeaders(NSAPIResponse.java:492)
        at
org.apache.catalina.connector.HttpResponseBase.finishResponse(HttpResponseBase.java:251)
        at
com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:180)
        at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)

Can somebody (please) confirm that there is a bug in Catalina code?

Links to relevant classes for your convenience:

*
http://svn.apache.org/repos/asf/tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/util/DateTool.java
*
http://svn.apache.org/repos/asf/tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/util/CookieTools.java(look
for DateTool usage)

Thanks,
    Anton.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message