Re: Possible thread safety problem in CachingWrapperFilter

2007-09-05 Thread Chris Hostetter
: I tried initializing the cache in the constructor, but then the test case : failed with a null pointer exception on the first synchronized(cache) . : Very strange, this seems to be a bug in the implementation of java : serialisation. The cache variable is transient, so it should not be affecte

Re: Possible thread safety problem in CachingWrapperFilter

2007-09-05 Thread Paul Elschot
On Tuesday 04 September 2007 21:03, Chris Hostetter wrote: > > : if (cache == null) { > : cache = new WeakHashMap(); > : } > : > : I think the initial snippet is not thread safe and might result > : in two threads initializing this cache to different objects, > : possibly conflictin

Re: Possible thread safety problem in CachingWrapperFilter

2007-09-04 Thread Yonik Seeley
On 9/4/07, Chris Hostetter <[EMAIL PROTECTED]> wrote: > : and should the cache accesses also use synchronized(this) ? > > I can't see a need for that ... then the same instance couldn't be used on > two distinct readers in parallel threads ... but that should be fine. synchronized (this) will prov

Re: Possible thread safety problem in CachingWrapperFilter

2007-09-04 Thread Paul Elschot
On Tuesday 04 September 2007 21:03, Chris Hostetter wrote: > > : if (cache == null) { > : cache = new WeakHashMap(); > : } > : > : I think the initial snippet is not thread safe and might result > : in two threads initializing this cache to different objects, > : possibly conflicti

Re: Possible thread safety problem in CachingWrapperFilter

2007-09-04 Thread Chris Hostetter
: if (cache == null) { : cache = new WeakHashMap(); : } : : I think the initial snippet is not thread safe and might result : in two threads initializing this cache to different objects, : possibly conflicting with the cache accesses after that: i believe you are write ... if Threa

Possible thread safety problem in CachingWrapperFilter

2007-09-04 Thread Paul Elschot
I'm trying to change the CachingWrapperFilter class to cache a SortedVIntList for LUCENE-584. That is progressing nicely, but I found this snippet at the beginning of the current CachingWrapperFilter.bits() method: if (cache == null) { cache = new WeakHashMap(); } I think the initi