lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Cherouvim ...@eworx.gr>
Subject SpellChecker AlreadyClosedException issue
Date Thu, 02 Apr 2009 10:52:39 GMT
Hello

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();
} catch (IOException ex) {
    log error
} finally {
    if (dir!=null) {
        try {
            dir.close();
        } catch (IOException ex) {
            log error
        }
    }
}


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
    at org.apache.lucene.store.Directory.ensureOpen(Directory.java:220)
    at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:481)
    at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:214)
    at 
org.apache.lucene.index.DirectoryIndexReader$1.doBody(DirectoryIndexReader.java:95)
    at 
org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:653)
    at 
org.apache.lucene.index.DirectoryIndexReader.open(DirectoryIndexReader.java:115)
    at org.apache.lucene.index.IndexReader.open(IndexReader.java:316)
    at org.apache.lucene.index.IndexReader.open(IndexReader.java:227)
    at org.apache.lucene.search.IndexSearcher.<init>(IndexSearcher.java:55)
    at 
org.apache.lucene.search.spell.SpellChecker.setSpellIndex(SpellChecker.java:116)
    at 
org.apache.lucene.search.spell.SpellChecker.<init>(SpellChecker.java:90)
    at 
org.apache.lucene.search.spell.SpellChecker.<init>(SpellChecker.java:95)


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.
Any ideas on what is wrong?

thanks
Ioannis Cherouvim

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message