dir is a local variable inside a method, so it's not getting reused.
Should I synchronise the whole method? I think that would slow things
down in a concurrent environment.
Thanks for your response.
Chris Hostetter wrote:
: My code looks like this:
:
: Directory dir = null;
: try {
: dir = FSDirectory.getDirectory("/path/to/dictionary");
: SpellChecker spell = new SpellChecker(dir); // exception thrown here
: // ...
: dir.close();
: This code works, but in a highly concurrent situation AlreadyClosedException
: is being thrown when I try to instantiate the SpellChecker:
: org.apache.lucene.store.AlreadyClosedException: this Directory is closed
if an error only happens under high concurrent load, it suggests that
perhaps you have multiple threads attempting to close the directory. you
haven't clarified whether "dir" is a local variable inside a method, or an
instnace variable in an object which is getting reused by multiple
threads -- so it's hard to guess.
: I use lucene-core-2.4.1.jar and lucene-spellchecker-2.4.1.jar and I can
: reproduce the error in both windows and linux.
if you have a fully exeuctable test case (instead of just an incomplete
partial snippet) that you can share, people may be able to spot the
problem, or at the very least run the test themselves to reproduce.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org
--
Ioannis Cherouvim
Software Engineer
mail: j...@eworx.gr
web: www.eworx.gr
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org