tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris R <chris.tech...@gmail.com>
Subject Race condition in DefaultServlet
Date Wed, 27 Jun 2012 16:33:01 GMT
Hi,

I am looking at the tomcat DefaultServlet code and I am afraid there seems
to be a race condition in there.
http://www.docjar.com/html/api/org/apache/catalina/servlets/DefaultServlet.java.html

>From doPut(...), there is a call to resources.lookup(path).
>From resources.lookup(...), there is a call to cacheLookup(name).
Within cacheLookup(..), there is a call to cache.lookup(name)
And in cache.lookup(...), accessCount, an instance variable is incremented.

If multiple threads call doPut(...), there is a possibility that they can
clobber each other and the value of
accessCount may not really give the exact number of accesses of the cache.
Can someone confirm whether this is a real problem?
How about adding a synchronization before this is updated?

Thanks,
Chris.

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