So CacheValidity objects should always take an extra Object parameter, which contains the string or whatever key is being hashed. The isValid function would then not just do its usual validity checking, it should also check the equality of those objects.
To be explicit, we could rewrite TimeStampCacheValidity to be hash clash safe as follows: private Object realKey; // the other key is "just" a hash which fits in a long. public TimeStampCacheValidity(long timeStamp, Object realKey) { this.timeStamp = timeStamp; this.realKey = realKey; } public boolean isValid(CacheValidity validity) { if (validity instanceof TimeStampCacheValidity) { return this.timeStamp == ((TimeStampCacheValidity)validity).getTimeStamp() && this.realKey.equals(validity.realKey); } return false; } Would this (or something like it since I haven't even compiled this) work? Or is something better planned for a future (imminent) release of Cocoon? (I didn't have any luck searching for the bug or TODO that you mentioned) Many thanks, Steve > -----Original Message----- > From: Vadim Gritsenko [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 19, 2002 2:05 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: Cocoon cache hash clash > > > > From: Stephen Ng [mailto:[EMAIL PROTECTED]] > > > > I'm confused by coocoon caching--what if I have use HashUtil in my > > generateKey, and two different pages/request happen to generate the > same > > hash key? Won't cocoon erroneously return the same page from the > cache? > > Only if validity matches. But it usually does not - result is > that these two pages won't be cached at all. Luckily, this > (almost) does not happen. > > There is a bug and a TODO item on this theme. > > Vadim > > > > Steve Ng > > Lumigent > > --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>