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

  • 相关阅读:
    腾讯视频插入网页的代码;
    FW: 软件持续交付的诉求;
    TOGAF
    Windows WSL2 htop打开黑屏的问题解决
    requests.exceptions.ConnectionError: HTTPSConnectionPool(host='appts.xxx.com%20', port=443):
    sqlalchemy实现模糊查询
    jenkins过滤版本,可选择版本
    QML 布局之一:锚布局详解(各种例子)
    Qt Quick 常用控件:Button(按钮)用法及自定义
    The Common Order Operations of Dis Operation System (DOSS)
  • 原文地址:https://www.cnblogs.com/a-du/p/6950207.html
Copyright © 2011-2022 走看看