Hi I have an Analyzer which is given a Config object and when tokenStream or reusableTokenStream is called, it generates a TokenStream based on the Config settings. I also have a setConfig method on that Analyzer. setConfig calls setPreviousTokenStream(null) so that next time reusableTokenStream is called, it will generate a new one, based on the new Config.
Before CloseableThreadLocal, this worked just fine. But now it fails on CTL's assert that the object held by the WeakReference is not null, w/ a comment "this cannot be null because we set it ...". I don't have access to tokenStreams member since it's private, therefore I can't just tokenStream = new CloseableThreadLocal(). Why doesn't CloseableThreadLocal allow for null objects? ThreadLocal allows it. Also, I think CTL is not consistent, since when I call set(null) it allows the call, but get() throws an exception. I can overcome this by setting a new object which its tokenizer and tokensteam members are null, and check those instead of the object returned from get(). But I don't think CTL should forbid null, or at least make sure a null cannot be set. What do you think? Shai