You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Richard Evans <rd...@webtrak.co.uk> on 2000/09/12 11:32:17 UTC

Thread worries

I'm worried about multithreading issues in tomcat on loaded sites.  We've
seen a problem in WebSphere 2 and I'm concerned the same issue may exist in
tomcat.

What happens is you get error 500s when a servlet is called a lot of times;
looking at backtraces shows that exceptions are being thrown when formatting
dates (for response headers presumably).  This is because SimpleDateFormat
is _NOT_ thread safe (see bug 4228335 on the javasoft bug parade); here's
part of a backtrace:

 at java.text.SimpleDateFormat.format(Compiled Code)
 at java.text.DateFormat.format(Compiled Code)
 at sun.servlet.http.HttpDate.toString(Compiled Code)
 at sun.servlet.http.MimeHeaderField.getValue(Compiled Code)
 at sun.servlet.http.MimeHeaders.getHeader(Compiled Code)

Now Tomcat has MimeHeaders and MimeHeaderField classes, perhaps derived from
Sun's.

Is it possible that tomcat could suffer from the same problems on a loaded
site, or was this problem known about and a fix put in?

Richard


Re: Thread worries

Posted by Richard Evans <rd...@webtrak.co.uk>.
Also all the code which uses any of the DateFormat objects in

     ./src/share/org/apache/tomcat/util/DateTool.java

Such as formatDate and parseDate in 

    ./src/share/org/apache/tomcat/util/MimeHeaderField.java

Richard

 > Hi there !
 > 
 > From a quick overview on the source the following sources might be 
 > affected by the 'SimpleDateFormat not thread safe' problem.
 > 
 > Neither of them explicitly syncronizes calls to SimpleDateFormat.format() 
 > or SimpleDateFormat.parse()
 > 
 > ./src/share/org/apache/tomcat/util/FastDateFormat.java
 > ./src/share/org/apache/tomcat/util/DateTool.java
 > ./src/share/org/apache/tomcat/request/StaticInterceptor.java
 > ./src/share/org/apache/tomcat/logging/Logger.java
 > 
 > ./proposals/catalina/src/share/org/apache/tomcat/util/FastDateFormat.java
 > ./proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet
 > .java
 > ./proposals/catalina/src/share/org/apache/tomcat/resources/DirectoryBean
 > .java
 > ./proposals/catalina/src/share/org/apache/tomcat/connector/HttpResponseB
 > ase.java
 > ./proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBa
 > se.java
 > 
 > Bernd
 > 
 > >>>>>>>>>>>>>>>>>> Urspr�ngliche Nachricht <<<<<<<<<<<<<<<<<<
 > 
 > Am 12.09.00, 11:32:17, schrieb "Richard Evans" <rd...@webtrak.co.uk> zum 
 > Thema Thread worries:
 > 
 > 
 > > I'm worried about multithreading issues in tomcat on loaded sites.  We've
 > > seen a problem in WebSphere 2 and I'm concerned the same issue may exist 
 > in
 > > tomcat.
 > 
 > > What happens is you get error 500s when a servlet is called a lot of 
 > times;
 > > looking at backtraces shows that exceptions are being thrown when 
 > formatting
 > > dates (for response headers presumably).  This is because 
 > SimpleDateFormat
 > > is _NOT_ thread safe (see bug 4228335 on the javasoft bug parade); here's
 > > part of a backtrace:
 > 
 > >  at java.text.SimpleDateFormat.format(Compiled Code)
 > >  at java.text.DateFormat.format(Compiled Code)
 > >  at sun.servlet.http.HttpDate.toString(Compiled Code)
 > >  at sun.servlet.http.MimeHeaderField.getValue(Compiled Code)
 > >  at sun.servlet.http.MimeHeaders.getHeader(Compiled Code)
 > 
 > > Now Tomcat has MimeHeaders and MimeHeaderField classes, perhaps derived 
 > from
 > > Sun's.
 > 
 > > Is it possible that tomcat could suffer from the same problems on a 
 > loaded
 > > site, or was this problem known about and a fix put in?
 > 
 > > Richard
 > 
 > 
 > > ---------------------------------------------------------------------
 > > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
 > > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
 > 
 > ---------------------------------------------------------------------
 > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
 > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
 > 
 > 

Re: Thread worries

Posted by Bernd Eilers <be...@stardivision.de>.
Hi there !

Re: Thread worries

Posted by Nick Bauman <ni...@cortexity.com>.
We've run into this issue at work, too. We solved it by making an object
pool for SimpleDateFormat.

On Tue, 12 Sep 2000, Richard Evans wrote:

> dates (for response headers presumably).  This is because SimpleDateFormat
> is _NOT_ thread safe (see bug 4228335 on the javasoft bug parade); here's
> part of a backtrace: