tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Cain <cc...@mhsoftware.com>
Subject Servlet Reloading Logic
Date Wed, 27 Sep 2000 00:56:32 GMT
I apologize if this is a known issue, but searching the list archives for "reload" returns
a painful amount of data. This is a 3.1
problem, but I glanced over the source for 3.2b4 and it appears it would have the same issue
(although I could be wrong). In any case,
I have already instituted a (very) rough fix on this end, so I am just passing the info along.

The problem: You have a servlet context set to reloading. In that context, you have two servlets:
ServletA and ServletB. If you
recompile ServletA, then access ServletB before accessing ServletA, ServletA will not be reloaded
until you restart Tomcat.

The reason is a subtle logic problem in the shouldReload() method. When ServletB checks to
see if it needs a reload, it checks the
last modified time for all repository files (presumably to see if any files that it relies
on have been updated). It finds a newer
file on disk (ServletA), so it empties out the entire cache (AdaptiveClassLoader.cache) and
reinitializes itself. In reinit'ing
itself, it now becomes the only entry in the cache. When you then hit ServletA, it now only
checks against the one cache file it has,
ServletB, and decides that no reloads are necessary.

Also of note, the default behavior for the "shouldReload(String className)" signature is to
avoid reload when no cache copy exists.

If this issue hasn't already been addressed, a few options occur to me off the top of my head:

1) Selectively set the "initialized" field on all modified classes (which requires checking
this field independently and before the
handleReload() call)
2) Selectively clear the cache (which would require shouldReload() to enumerate the repository
files instead of the cache, and making
the default behavior of "no cache entry found" to be a reload)

I'm not sure about performance cost and/or miscellaneous ramifications of either approach,
I'm just tossing out ideas. I didn't
include my patch because a) It ignores any dependencies, because I don't have any, b) I'm
not sure if this is a known/resolved issue.
If this *is* a resolved issue, I would be interested to how you solved it - strictly out of
curiosity.

Regards ...

- Christopher


Mime
View raw message