Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/LuceneIndex.java @ 527:ef0336efe33c
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 May 2015 03:29:04 -0600 |
parents | 70bda9184158 |
children | c5a93767cc5c |
line wrap: on
line diff
--- a/lucene/src/luan/modules/lucene/LuceneIndex.java Wed May 27 03:20:38 2015 -0600 +++ b/lucene/src/luan/modules/lucene/LuceneIndex.java Wed May 27 03:29:04 2015 -0600 @@ -1,5 +1,6 @@ package luan.modules.lucene; +import java.io.Closeable; import java.io.File; import java.io.FileOutputStream; import java.io.FileInputStream; @@ -35,7 +36,7 @@ import org.slf4j.LoggerFactory; -public final class LuceneIndex { +public final class LuceneIndex implements Closeable { private static final Logger logger = LoggerFactory.getLogger(LuceneIndex.class); private static final String FLD_NEXT_ID = "nextId"; @@ -48,7 +49,6 @@ private LuceneSearcher searcher; public final FieldTable fields = new FieldTable(); private boolean isClosed = false; - private final Runnable closer; public LuceneIndex(LuanState luan,String indexDirStr) throws LuanException, IOException { File indexDir = new File(indexDirStr); @@ -62,14 +62,7 @@ writer = new IndexWriter(dir,conf); writer.commit(); // commit index creation reader = DirectoryReader.open(dir); - closer = new Runnable(){public void run(){ - try { - close(); - } catch(IOException e) { - logger.error("",e); - } - }}; - luan.onClose(closer); + luan.onClose(this); searcher = new LuceneSearcher(this,reader); initId(luan); }