lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Possible thread safety problem in CachingWrapperFilter
Date Wed, 05 Sep 2007 22:01:17 GMT

: 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 affected
: at all by serialisation, but it appears to be affected nonetheless.

Ahhh... that actally makes a lot of sense.  transient fields won't be 
saved/restored in serialization, so initing only in the constructor isn't 
good enough, after it's been serialized it will be null.

: I had a quick look at the java serialisation spec, and iirc it was
: also mentioned that one might use a final variable initialized in
: the constructor. I did not try that (final transient cache), i preferred

I can't even fathom what it would mean to be both final and transient ... 
they seem diametricaly opposed to me (but it doesn't generate a compiler 
warning, so it must mean something)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message