zoukankan      html  css  js  c++  java
  • 解决org.apache.lucene.store.AlreadyClosedException: this Directory is closed

    在Lucene中,关闭一个IndexWriter时抛出AlreadyClosedException异常:

    org.apache.lucene.store.AlreadyClosedException: this Directory is closed

    at org.apache.lucene.store.BaseDirectory.ensureOpen(BaseDirectory.java:66) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.store.FSDirectory.deleteFile(FSDirectory.java:269) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexFileDeleter.deleteFile(IndexFileDeleter.java:595) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexFileDeleter.deleteNewFiles(IndexFileDeleter.java:582) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.deleteNewFiles(IndexWriter.java:4693) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.DocumentsWriter$DeleteNewFilesEvent.process(DocumentsWriter.java:739) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.processEvents(IndexWriter.java:4746) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.processEvents(IndexWriter.java:4738) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3198) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3170) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.closeInternal(IndexWriter.java:991) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:935) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:897) ~[lucene-core-4.8.1.jar:4.8.1 1594670 – rmuir – 2014-05-14 19:22:52]

    有人说这是因为index目录下的write.lock没有被删除,其实并不是这样。

    真正的原因是,IndexWriter依赖于一个Directory,当Directory关闭的时候,IndexWriter也就随之关闭了。所以正确的关闭顺序是

    1. 先关闭IndexWriter

    2. 后关闭Directory

  • 相关阅读:
    intellij idea 修改web端口号
    intellij idea有时候有时候服务器报错500
    由于没有更新主分支的代码,总是报警
    intellij idea 快捷键
    intellij idea 修改文件名失败
    [Introduction to programming in Java 笔记] 1.3.8 Gambler's ruin simulation 赌徒破产模拟
    [Introduction to programming in Java 笔记] 1.3.7 Converting to binary 十进制到二进制的转换
    C++学习笔记-2-构造函数和析构函数
    python学习笔记--随时更新
    C++学习笔记-1-自增和自减运算符
  • 原文地址:https://www.cnblogs.com/a-du/p/6950207.html
Copyright © 2011-2022 走看看