LUCENE-10024: Catch NoSuchFileException when opening index directory

This commit is contained in:
Michael Wechner 2021-07-17 13:43:12 +09:00 committed by Tomoko Uchida
parent 982b95e38e
commit 489ba3e4f9
2 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,7 @@
package org.apache.lucene.luke.app;
import java.lang.invoke.MethodHandles;
import java.nio.file.NoSuchFileException;
import java.util.Objects;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.index.IndexReader;
@ -71,6 +72,12 @@ public final class IndexHandler extends AbstractHandler<IndexObserver> {
IndexReader reader;
try {
reader = IndexUtils.openIndex(indexPath, dirImpl);
} catch (NoSuchFileException e) {
log.error("Error opening index", e);
throw new LukeException(
MessageUtils.getLocalizedMessage(
"openindex.message.index_path_does_not_exist", indexPath),
e);
} catch (Exception e) {
log.error("Error opening index", e);
throw new LukeException(

View File

@ -71,6 +71,7 @@ openindex.radio.keep_only_last_commit=Keep only last commit point
openindex.radio.keep_all_commits=Keep all commit points
openindex.message.index_path_not_selected=Please choose index path.
openindex.message.index_path_invalid=Cannot open index path {0}. Not a valid lucene index directory or corrupted?
openindex.message.index_path_does_not_exist=Cannot open index path {0}. No such directory!
openindex.message.index_opened=Index successfully opened.
openindex.message.index_opened_ro=Index successfully opened. (read-only)
openindex.message.index_opened_multi=Index successfully opened. (multi-reader)