On 11/11/2008, Anton Khitrenovich <[EMAIL PROTECTED]> wrote:
> 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."
>

BTW, Commons LANG has a thread-safe FastDateFormat which can be used
instead of SimpleDateFormat#format(). However LANG does not have
versions of the parse() methods:

http://commons.apache.org/lang/api/org/apache/commons/lang/time/FastDateFormat.html

Might be worth considering to avoid the expense of per-thread copies
of the class.

>  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.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to